I created a Java application with hibernate and MySQL.
I have two databases and use both databases in hibernate.
When I insert a record to the first database with hibernate and query the database (this query is a SQL query and uses both databases) no data is changed.
I have two Configure File for two database in hibernate.
These two files are the same and are different in database name and Entity.
Config:
org.hibernate.dialect.MySQLDialect
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/Depot
root
true
UTF-8
UTF-8
true
update
50
クエリ:
private final String _hql = "SELECT detail.SBdId, sale.SBNo, customer.CusCharacter, sale.SBDate, part.PaPartNumber, CONCAT(detail.SBdName,' ',type.PtName,' ',kin.PkName,' ',dev.PdName), detail.SBdCount, detail.SBdPrice,detail.SBdDiscount,"
+ "(detail.SBdCount * detail.SBdPrice)-detail.SBdDiscount AS Expr1, detail.SBdDesc,sale.SBDiscount,sale.SBDesc,Sum(rt.ReSBCount) "
+ "FROM Sale_Buy AS sale INNER JOIN "
+ "Customer AS customer ON sale.CusId = customer.CusId INNER JOIN "
+ "Sale_BuyDetail AS detail ON sale.SBId = detail.SBId LEFT OUTER JOIN "
+ "Sale_BuyReturn AS rt ON detail.SBdId=rt.SBdId LEFT OUTER JOIN "
+ "Depot.Part AS part ON detail.PaPartNumber = part.PaId LEFT OUTER JOIN "
+ "Depot.PartDevice AS dev ON part.PdId=dev.PdId LEFT OUTER JOIN "
+ "Depot.PartKind AS kin ON part.PkId=kin.PkId LEFT OUTER JOIN "
+ "Depot.PartType As type ON part.PtId=type.PtId Where sale.SBId>0 ";