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]
|