在Hibernate中刷新缓存

时间:2012-02-06 12:27:43

标签: java hibernate

我用hibernate和MySQL创建了一个Java应用程序 我有两个数据库并在休眠中使用这两个数据库 当我使用hibernate将记录插入第一个数据库并查询数据库(此查询是SQL查询并使用两个数据库)时,不会更改任何数据。
我在休眠中有两个配置文件用于两个数据库 这两个文件是相同的,在数据​​库名称和实体上是不同的 配置:

  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Depot</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.useUnicode">true</property>
  <property name="hibernate.connection.characterEncoding">UTF-8</property>
  <property name="hibernate.connection.charSet">UTF-8</property> 
  <property name="hibernate.show_sql">true</property>
  <property name="hdm2ddl.auto">update</property>
  <property name="hibernate.jdbc.batch_size">50</property>

查询:

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 ";

0 个答案:

没有答案