草庐IT

Hibernate-Validator

全部标签

java - Hibernate:未能延迟初始化角色集合,没有 session 或 session 已关闭

我的代码:@TestpublicvoidtestAddRoleAndAddUser(){Roler=roleDao.findByProperty("name","admin");if(r==null){r=newRole();r.setName("admin");r.setDescription("Justadministrator.");roleDao.save(r);}Useru=dao.get(1l);Setroles=u.getRoleSet();logger.debug("Rolesisnull:"+(roles==null));roles.add(r);dao.save(u

java - Hibernate:未能延迟初始化角色集合,没有 session 或 session 已关闭

我的代码:@TestpublicvoidtestAddRoleAndAddUser(){Roler=roleDao.findByProperty("name","admin");if(r==null){r=newRole();r.setName("admin");r.setDescription("Justadministrator.");roleDao.save(r);}Useru=dao.get(1l);Setroles=u.getRoleSet();logger.debug("Rolesisnull:"+(roles==null));roles.add(r);dao.save(u

java - 批量插入中的 Postgres 错误 : relation "hibernate_sequence" does not exist position 17

我正在执行hibernatejpa批量更新,它给了我以下错误2015-04-2115:53:51,907WARN[org.hibernate.engine.jdbc.spi.SqlExceptionHelper](Thread-283(HornetQ-client-global-threads-462057890))SQLError:0,SQLState:42P012015-04-2115:53:51,908ERROR[org.hibernate.engine.jdbc.spi.SqlExceptionHelper](Thread-283(HornetQ-client-global-t

java - 批量插入中的 Postgres 错误 : relation "hibernate_sequence" does not exist position 17

我正在执行hibernatejpa批量更新,它给了我以下错误2015-04-2115:53:51,907WARN[org.hibernate.engine.jdbc.spi.SqlExceptionHelper](Thread-283(HornetQ-client-global-threads-462057890))SQLError:0,SQLState:42P012015-04-2115:53:51,908ERROR[org.hibernate.engine.jdbc.spi.SqlExceptionHelper](Thread-283(HornetQ-client-global-t

java - Hibernate Query By Example 和 Projections

简而言之:hibernate不支持投影和示例查询?我找到了这篇文章:代码是这样的:Userusr=newUser();usr.setCity='TEST';getCurrentSession().createCriteria(User.class).setProjection(Projections.distinct(Projections.projectionList().add(Projections.property("name"),"name").add(Projections.property("city"),"city"))).add(Example.create(usr)

java - Hibernate Query By Example 和 Projections

简而言之:hibernate不支持投影和示例查询?我找到了这篇文章:代码是这样的:Userusr=newUser();usr.setCity='TEST';getCurrentSession().createCriteria(User.class).setProjection(Projections.distinct(Projections.projectionList().add(Projections.property("name"),"name").add(Projections.property("city"),"city"))).add(Example.create(usr)

java - 为什么我得到 org.hibernate.HibernateException : No CurrentSessionContext configured

我正在编写一个简单的项目,一个用Swing编写的商业应用程序,后端使用Hibernate。我来自Spring,这给了我使用hibernate和事务的简单方法。无论如何,我设法让Hibernate工作。昨天,在编写一些代码从数据库中删除一个bean时,我得到了这个:org.hibernate.HibernateException:Illegalattempttoassociateacollectionwithtwoopensessions删除代码很简单:Sessionsess=HibernateUtil.getSession();Transactiontx=sess.beginTrans

java - 为什么我得到 org.hibernate.HibernateException : No CurrentSessionContext configured

我正在编写一个简单的项目,一个用Swing编写的商业应用程序,后端使用Hibernate。我来自Spring,这给了我使用hibernate和事务的简单方法。无论如何,我设法让Hibernate工作。昨天,在编写一些代码从数据库中删除一个bean时,我得到了这个:org.hibernate.HibernateException:Illegalattempttoassociateacollectionwithtwoopensessions删除代码很简单:Sessionsess=HibernateUtil.getSession();Transactiontx=sess.beginTrans

java - Hibernate Criteria API 中 Restrictions.like 和 .ilike 的区别

Hibernate的CriteriaAPI具有Restrictions.ilike函数,该函数具有以下协定:Acase-insensitive"like",similartoPostgresilikeoperator这很酷。但是同一个类也有like功能,契约(Contract)更加模糊:Applya"like"constrainttothenamedproperty例子Criteriacr=session.createCriteria(Employee.class);//TogetrecordshavingfistNamestartingwithzaracr.add(Restricti

java - Hibernate Criteria API 中 Restrictions.like 和 .ilike 的区别

Hibernate的CriteriaAPI具有Restrictions.ilike函数,该函数具有以下协定:Acase-insensitive"like",similartoPostgresilikeoperator这很酷。但是同一个类也有like功能,契约(Contract)更加模糊:Applya"like"constrainttothenamedproperty例子Criteriacr=session.createCriteria(Employee.class);//TogetrecordshavingfistNamestartingwithzaracr.add(Restricti