随笔分类 - hibernate
摘要:Hibernate1,error:Path expected for join!错误的写法:select lin from LoginInfo lin join person where lin.loginId =?正确的写法: select lin from LoginInfo lin join lin.person where lin.loginId =?注意:用这种方法进行关联查询的话,要确保对几个相关联实体的获取都要在session.getTransaction().commit();语句之前,即在session未关闭之前,否则会报问题2一样的错误。2,error:org.hibern
阅读全文
摘要:根据主键直接获得对象:customer = (Customer) sess.get(Customer.class, 1);或customer = (Customer) sess.load(Customer.class, 1);使用SQL的实体查询List users = (List<Customer>) sess.createSQLQuery("select * from CUSTOMER") .addEntity(Customer.class) .list();Iterator it = users.iterator();customer = (Custome
阅读全文
摘要:A hibernate.properties文件hibernate.dialect org.hibernate.dialect.MySQL5InnoDBDialecthibernate.connection.driver_class com.mysql.jdbc.Driverhibernate.connection.url jdbc:mysql://localhost:3306/hibernatehibernate.connection.username hibehibernate.connection.password 1234hibernate.connection.pool_size 5
阅读全文
摘要:A 在3.6.8版本中,可以直接用SessionFactory sf = new Configuration() .configure() // 直接用hibernate.cfg.xml来进行配置和创建 .buildSessionFactory();B 在4.0.0版本中,因Configuration().configure()方法被废除了,故用以下方式来创建Configuration config = new Configuration() .addResource("org/monday/domain/Customer.hbm.xml");ServiceRegistry
阅读全文
浙公网安备 33010602011771号