我的程序有一个用户和一个安全的角色配置,这两个模型之间存在多对多关系。当我试图将一个新用户和他的m- to -m关系保存在一个单独的名为"user_roles“的表中时,session.save()函数出现以下错误: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions. Collection : [com.session.library.libraryofbooks.model.Role.employees#1] 下面是我的用户模型代码:
Transformers.aliasToBean(User.class));
当您使用Hibernate时,这是非常棒的,但是我也试图对JPA(JPA提供程序是Hibernate tho)做同样的工作。可以用JPA吗?--我的意思是用CriteriaBuilder限制列并映射到特定的对象?Eventually, Hibernate-specific criteria features will be ported as extensions to the J