-->
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.  [ 2 posts ] 
Author Message
 Post subject: problem when the n-side has composite-id
PostPosted: Wed Sep 10, 2003 4:15 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi (again :(),
I have :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.diatem.src.Team" table="teams">
<id name="id" column="team_id" type="long" unsaved-value="null">
<generator class="sequence"/>
</id>
<property name="name" column="team_name" type="string" length="15" not-null="true"/>
<property name="city" column="city" type="string" length="15" not-null="true"/>

<set name="players" cascade="all" inverse="true" lazy="true">
<key column="team_id"/>
<one-to-many class="com.diatem.src.Player"/>
</set>
</class>

</hibernate-mapping>

and

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.diatem.src.Player" table="players" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false">

<composite-id name="compId" class="com.diatem.src.PlayerID" unsaved-value="none">
<key-property name="alias" column="alias_" type="string"/>
</composite-id>

<property name="firstName" column="first_name" type="string" length="12" not-null="true"/>
<property name="lastName" column="last_name" type="string" length="15" not-null="true"/>
<property name="draftDate" column="draft_date" type="date"/>
<property name="annualSalary" column="salary" type="float"/>
<property name="jerseyNumber" column="jersey_number" type="integer" length="2" not-null="true"/>

<many-to-one name="team" class="com.diatem.src.Team" column="team_id"/>

</class>

</hibernate-mapping>

and I get:

...................
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
Hibernate: values nextval for hibernate_sequence
Hibernate: insert into teams (team_name, city, team_id) values (?, ?, ?)
Hibernate: update players set first_name=?, last_name=?, draft_date=?, salary=?, jersey_number=?, team_id=? where alias_=?
com.diatem.persistence.BusinessException: net.sf.hibernate.HibernateException: SQL update or deletion failed (row not found)
at com.diatem.persistence.PersistentSession.flush(PersistentSession.java:44)
at com.diatem.src.Main.testSaveTeam(Main.java:140)
at com.diatem.src.Main.go(Main.java:54)
at com.diatem.src.Main.main(Main.java:34)
Caused by: net.sf.hibernate.HibernateException: SQL update or deletion failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:642)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:611)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:31)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2100)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2062)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005)
at com.diatem.persistence.HibernateSession.flush(HibernateSession.java:52)
at com.diatem.persistence.PersistentSession.flush(PersistentSession.java:42)
... 3 more

Please help !

Thanks very much,
--steve


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 10:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
And, ummm, what did you *do* to get that?

Anyway, most likely all you need to do is change to unsaved-value="any". Please read "Parent/CHild Relationship"


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

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.