-->
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.  [ 4 posts ] 
Author Message
 Post subject: Version property with many-to-many association?
PostPosted: Thu May 06, 2004 11:49 am 
Regular
Regular

Joined: Thu Apr 29, 2004 5:08 pm
Posts: 56
Location: Montreal, Quebec, Canada
I have a association table for a many to many relation. This table contains extra fields.

So I have the following tables / objects:

Person
id
name

PersonLanguage
personId
languageId
speaked
written
updateCount

Language
id
code

The mapping, from the Person.hbm.xml file, looks like this:

Code:
<set name="languages" table="Person_Language">
    <key column="Version_Id"/>
    <composite-element class="PersonLanguage">
        <property name="guiOnly" column="speaked" type="boolean"/>
        <property name="guiDefault" column="written" type="boolean"/>
        <many-to-one name="language" class="Language" column="Language_Id" outer-join="false"/>
    </composite-element>
</set>


The problem is that I'm using optimistic locking with a version property. In our current (and established) database schema, we have a version column for the association table

Person_Language
update_count

However, I can't specify a <version> tag in a <composite-element> tag.

How can I map a version property for optimistic locking residing in an association table?

_________________
- Frank


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 11:53 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can't. Use a database trigger to update the version in that table and don't map it, Hibernate doesn't need it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 12:29 pm 
Regular
Regular

Joined: Thu Apr 29, 2004 5:08 pm
Posts: 56
Location: Montreal, Quebec, Canada
Unbelievable!!!

1. I submitted my question
2. I printed the JBoss Training form to be part of the training in NY (2 pages)
3. I came back at my desk and had already an answer

Awesome! heheh

Thanks!

_________________
- Frank


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 8:55 pm 
Regular
Regular

Joined: Thu Apr 29, 2004 5:08 pm
Posts: 56
Location: Montreal, Quebec, Canada
I'm now using a class (and a mapping) even for join-table (tables used to associate 2 entities using a many-to-many relation).

Since mapped, it may have a version property as any other entities.

I consider the relation as being an entity by itself.

Thanks

_________________
- Frank


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