-->
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: "Found two representations of same collection" in
PostPosted: Fri Aug 13, 2004 5:51 pm 
Newbie

Joined: Fri Aug 13, 2004 5:00 pm
Posts: 3
Location: Germany
Dear group,

I jused hibernate as our persitence mechanism for the brand new project.
That far it I could get it work. But now I ran into a problem I can't solve on my one.
First the context:
We're using coconn for a web-app and hibernate as the persistence mechanism. I read all the hibernate stuff at cocoon and ended up with a HibernateFactory which is a cocoon-Persistence Factory and two Registries: a UserRegistry and a Workflow registry. Both Registries get the same hibernate session from the hibernate factory. The session is opened via sf.openSession()
The User registry loads users from the db and is used within the cocoon-auth-framework. All that works good.

Now my problem:
Within the Auth-stuff I load the current user and store it into the cocoon session (which is nothing but a collection, i think):

List myUsers = hs.find("from user in class User where user.login = ?", loginName,Hibernate.STRING);
User user = (User) myUsers.get(0);
cocoonsession.setAttribute(nameInSession, user);


At another point I retrieve that User from the cocoon-session and change it. Afterwards I try to save it. Here's that snippet:

Code between sessionFactory.openSession() and session.close():
This code occurs within the method ChangeMemberEntry.getDataFromRequest(...)


User currentUser = (User) cocoonsession.getAttribute(nameInSession);
converter.convertRequestToObject(rq, currentUser);// this changes the user
try {
session.saveOrUpdate(currentUser); // I also tried just "save"
session.flush(); // The exception occurs at that point



But it does not work. It results in the "Found two representations of same collection"-Exception.
The only collection the user has is a "WorkflowStep".
I have a model like that

User<-1-----------*->WorkflowStep<-*----------1->PersistantWorkflow

The Hibernate mappings are given below.
I searched hours and hours but I don't have an idea about what's going on here. I think this usage isn't that strange.
Could please anyone give me a hint about what I'm doing wrong.
I don't know wheather my model is wrong or I mistread the hibernate sessions. Did I misunderstood the hibernate archtecture?

Thanks in advance for any hint.

Helge Hofmeister

Hibernate version: 2.1.4

Mapping documents:
The User:
<hibernate-mapping>
-
<class name="de.ecoware.etap.persistenz.model.User" table="User" dynamic-update="false" dynamic-insert="false">
-
<id name="id" column="USER_ID" type="java.lang.Integer">
<generator class="native">
</generator>
</id>
<property name="login" type="java.lang.String" update="true" insert="true" access="property" column="login"/>
<property name="nachname" type="java.lang.String" update="true" insert="true" access="property" column="nachname"/>
<property name="passwd" type="java.lang.String" update="true" insert="true" access="property" column="passwd"/>
<property name="rolle" type="java.lang.String" update="true" insert="true" access="property" column="rolle"/>
<property name="vorname" type="java.lang.String" update="true" insert="true" access="property" column="vorname"/>
<property name="anrede" type="java.lang.String" update="true" insert="true" access="property" column="anrede"/>
<property name="titel" type="java.lang.String" update="true" insert="true" access="property" column="titel"/>
<property name="strasse" type="java.lang.String" update="true" insert="true" access="property" column="strasse"/>
<property name="strasse_nr" type="java.lang.String" update="true" insert="true" access="property" column="strasse_nr"/>
<property name="plz" type="java.lang.String" update="true" insert="true" access="property" column="plz"/>
<property name="ort" type="java.lang.String" update="true" insert="true" access="property" column="ort"/>
<property name="land" type="java.lang.String" update="true" insert="true" access="property" column="land"/>
<property name="email" type="java.lang.String" update="true" insert="true" access="property" column="email"/>
-
<set name="steps" lazy="true" inverse="true" cascade="save-update" sort="unsorted">
<key column="FK_USER_ID">
</key>
<one-to-many class="de.ecoware.etap.persistenz.model.WorkflowStep"/>
</set>

</class>
</hibernate-mapping>

The WorkflowStep:
<hibernate-mapping>
-
<class name="de.ecoware.etap.persistenz.model.WorkflowStep" table="WORKFLOW_STEP" dynamic-update="false" dynamic-insert="false">
-
<id name="id" column="STEP_ID" type="java.lang.Integer">
<generator class="native">
</generator>
</id>
<property name="step" type="java.lang.Integer" update="true" insert="true" access="property" column="step"/>
<many-to-one name="user" class="de.ecoware.etap.persistenz.model.User" cascade="none" outer-join="auto" update="true" insert="true" access="property" column="FK_USER_ID"/>
<many-to-one name="workflow" class="de.ecoware.etap.persistenz.model.PersistantWorkflow" cascade="none" outer-join="auto" update="true" insert="true" access="property" column="FK_WORKFLOW_ID"/>

</class>
</hibernate-mapping>

The Workflow:
<hibernate-mapping>
-
<class name="de.ecoware.etap.persistenz.model.PersistantWorkflow" table="workflow" dynamic-update="false" dynamic-insert="false">
-
<id name="id" column="WF_ID" type="java.lang.Integer">
<generator class="native">
</generator>
</id>
<property name="javaClassName" type="java.lang.String" update="true" insert="true" access="property" column="javaClassName"/>
-
<set name="steps" lazy="true" inverse="true" cascade="save-update" sort="unsorted">
<key column="FK_WORKFLOW_ID">
</key>
<one-to-many class="de.ecoware.etap.persistenz.model.WorkflowStep"/>
</set>

<property name="url" type="java.lang.String" update="true" insert="true" access="property" column="url"/>

</class>
</hibernate-mapping>



The Stack trace:
net.sf.hibernate.HibernateException: Found two representations of same collectio
n
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionIm
pl.java:2866)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.jav
a:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.ja
va:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.j
ava:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2588)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2454
)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:22
56)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2235)
at de.ecoware.etap.workflowdescription.ChangeMemberEntry.getDataFromRequ
est(ChangeMemberEntry.java:55)
...
...


Name and version of the database you are using: MySQL 4.1.3


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.