Hi all, is there any one know this exception? Currently I was integrating with Spring, Hibernate and ZK framework. Because of ZK, I may need to use persistence for merging purposes.
Below source is my partially implementation for this:
User Zul:
...
<listitem self="@{each='userBean'}" value="@{userBean,
converter='com.ersm.util.HibernateSessionMergeConverter'}"
onDoubleClick="userController.onEdit()">
<listcell label="@{userBean.login}"/>
<listcell label="@{userBean.firstName}"/>
<listcell label="@{userBean.lastName}"/>
<listcell label="@{userBean.role.name}"/>
</listitem>
...
HibernateSessionMergeConverter:
...
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistenceManager");
EntityManager em = emf.createEntityManager();
if(val instanceof GenericBean){
em.merge(val);
}
...
persistence.xml:
...
<persistence-unit name="persistenceManager" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!--mapping-file>/com/ersm/common/bean/user/User.hbm.xml</mapping-file-->
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/ersm"></property>
<property name="hibernate.connection.username" value="root"></property>
<property name="hibernate.connection.password" value=""></property>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"></property>
</properties>
</persistence-unit>
</persistence>
...
First of all, I define the class in the persistence.xml but it causes:
java.lang.IllegalArgumentException: Unknown entity: com.ersm.common.bean.user.User
... then I remove the class and define the mapping-file, however, it causes
javax.persistence.PersistenceException: org.hibernate.DuplicateMappingException: Duplicate collection role mapping User.riskGroups
For more information about the problem behind, you may refer to this blog:
http://www.zkoss.org/forum/index.zul#path%3DlistComment%3BdiscussionId%3D7252%3BcategoryId%3D14%3B
Your help and guidance is highly appreciated.[/i]