-->
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.  [ 3 posts ] 
Author Message
 Post subject: Key Violation seemed to start with upgrade to 3.0
PostPosted: Sun Mar 13, 2005 3:40 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
I have a 1->Many collection The Many being in the form of a Map.

Specifically the Relationship is User->UserLanguage. The Map of UserLanguage objects is keyed on languageCode. Said Map and initialized UserLanguage instances are populated in the User class constructor.

Anyway, what I am experiencing is that when I save an instance of User initially, it works great, persisting the UserLanguage records. No problem.

But when I retrieve the User class, things get weird.

If I do:

user.getLanguage("en").setLanguageProficiencyCode("0");
session.update(user);

I get JDBC Exception:

01:48:40,322 ERROR JDBCExceptionReporter:58 - Duplicate key or integrity constraint violation message from server: "Duplicate entry '10-en' for key 2"


I thought this had been working unti the upgrade to Hibernate 3...

I'm hoping it's something obvious. TIA


Hibernate version: 3.0 rc1


Mapping documents:
[code]
<hibernate-mapping>
<class
name="bb.model.UserLanguage"
table="UserLanguage"
dynamic-update="true"
dynamic-insert="true"
>

<id
name="id"
column="Id"
type="java.lang.Integer"
unsaved-value="null"
>
<generator class="identity">
</generator>
</id>

<many-to-one
name="user"
class="bb.model.User"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="UserId"
/>

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

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

</class>

</hibernate-mapping>

User Mapping is snipped. It's actually a joined subclass of UserEntity

<joined-subclass
name="bb.model.User"
table="User"
dynamic-update="true"
dynamic-insert="true"
>
<key
column="UserId"
/>
<property
name="gender"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="gender"
/>

<property
name="birthDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="birthDate"
/>


<map
name="languages"
lazy="true"
sort="unsorted"
inverse="true"
cascade="all"
>

<key
column="UserId"
>
</key>

<index
column="LanguageCode"
type="string"
/>

<one-to-many
class="bb.model.UserLanguage"
/>

</map>

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 13, 2005 3:46 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
Basically it's trying to do an insert on the same UserLanguage record it retrieved rather than doing an update.

The only thing I can think of is that I have somehow munged the User record I retrieved, making Hibernate think it's not the same record I had before (but then I would expect to see the User record have an attempted insert first).


I'm really scratching my head here...

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 1:46 pm 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
Problem caused Bug in BeanUtils.

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.