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".
|
|