-->
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: Get NonUniqueObjectException with use of composite-id
PostPosted: Wed Sep 27, 2006 10:39 am 
Newbie

Joined: Wed Sep 27, 2006 9:55 am
Posts: 1
Hi,

im new to hibernate and am experiencing problems with use of composite-id, i cant figure out what to do now, used several hours without result.

I have 2 foreign keys in this table ("PropertyForAirPlane"). i get an exception when trying to save (insert) into this PropertyForAirPlane. I have implemented both the equals and and hashcode methods in PropertyForAirPlane and Property class so i cant understand why i get an net.sf.hibernate.NonUniqueObjectException. Any idea, please help ?


Hibernate version:
2.1.7

Mapping documents:

<class name="PropertyForAirPlane">
<composite-id>
<key-property name="Airplaneid" type="int"/>
<key-many-to-one name="property" class="Property" column="propertyId" />
</composite-id>
<property name="deleted" type="boolean"/>
</class>


<class name="Airplane">
<id name="id" type="int" unsaved-value="0">
<generator class="identity" />
</id>

<property name="airplaneNo" type="string" />
<property name="week" type="string" />
<property name="deleted" type="boolean" />


<set name="properties" cascade="all">
<key column="Airplaneid" />
<one-to-many class="PropertyForAirPlane"/>
</set>
</class>


..........
..........


Stack trace of any exception that occurs:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: Plassreservering mulig, of class: no.arrive.rutepub.data.AttributtForTogRutetabell
at net.sf.hibernate.impl.SessionImpl.checkUniqueness(SessionImpl.java:1687)
at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1453)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1480)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1403)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)



The generated SQL (show_sql=true):
Hibernate: insert into PropertyForAirPlane(airplaneNo, week, deleted) values (?, ?, ?, ?) select scope_identity()
Hibernate: insert into PropertyForAirPlane(airplaneNo, week, deleted) values (?, ?, ?, ?) select scope_identity()
27.sep.2006 15:47:57 net.sf.hibernate.impl.SessionFactoryImpl close
INFO: closing
27.sep.2006 15:47:57 net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:microsoft:sqlserver://133.61.56.32:1433;databasename=AirDB;SelectMethod=Cursor
2006-09-27 15:47:57,797 no.airplane.AirplaneAdapter|http-9700-Processor24 |[myuser(34:*:69695f)@NSB(4:*:c3d062) httpParametersProcess] savingtable failed
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: Leaterseats, of class: no.airplane.data.PropertyForAirPlane
[/b]


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.