-->
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: insert="false" update="false"
PostPosted: Wed Sep 27, 2006 4:34 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
I have a situation where I have a one-to-one mapping, but I have to use a constrained many-to-one.

table A
- a_id

table B (has a composite id with the following columns)
- a_id
- b_type

table C (has a composite id with the following columns)
- a_id
- c_type

I just added a mapping for table B, which has a relation to table C. The *_type for each table doesn't really matter except for the fact that they are part of a composite id for each table. I have successfully used the following mapping to work with this relationship.

Code:
...
<class name="B">
...
<many-to-one  name="c"
                       class="foo.C"
                       cascade="all"
                       unique="true"
                       insert="false"
                       update="false">
    <column name="THIS_IS_IGNORED_1"/>
    <column name="THIS_IS_IGNORED_2"/>
</many-to-one>
...
</class>



The above mapping mysteriously works and I'm wondering why.

1. I originally thought the column names would have to match up to a table, but this isn't the case. I can make the column names whatever I want. It doesn't matter what the values are.

2. Hibernate DOES complain if I remove one of the column tags. This is because it wants the same number of column tags as there are columns in the primary key of the other table.

3. Hibernate DOES look at the names of the columns if I remove the insert="false" update="false".

Can someone explain why this works? Also, I don't see much domentation on the insert and update values. Can someone explain the behavior of these attributes or point me to the documentation?


Thanks in advance,

_________________
Michael Masters


Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 10, 2006 10:50 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
I've found that I don't get any problems if I save, but I do run into a problem when I try to retrieve the object. I'm using spring's AbstractTransactionalSpringContextTests so my save and retrieve were being done in the same session, hence I wasn't getting an error for the retrieval. If I flush the session before the retrieval, then I get errors. In this case, it is using the columns specified.

I'm still trying to map this situation if anyone has any advice :)

_________________
Michael Masters


Don't forget to rate.


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.