-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Integrate Hibernate with ZK causing exception
PostPosted: Wed Mar 04, 2009 3:00 am 
Newbie

Joined: Wed Mar 04, 2009 2:42 am
Posts: 2
Location: Malaysia
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.