-->
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.  [ 6 posts ] 
Author Message
 Post subject: Column apearing twice in update statement - help
PostPosted: Mon Jun 13, 2005 3:29 pm 
Beginner
Beginner

Joined: Fri May 13, 2005 11:48 am
Posts: 32
I have a composite key for my lookup tables that lets me store the language that the lookup is rendered in. I then have the key and the language as a composite pk. In order to use it else where I have to store the key and language as a composite foriegn key. I map the language to a language column and I also map a property Language to that same column. The problem is that I now have the Language column apearing twice in my SQL statements which SQL Server doesn't like. How can I avoid saving one of these languages?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 13, 2005 4:08 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Um, I got lost in all those languages a bit :) but the general solution is to use insert="false" update="false" attributes of <property> tag.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 13, 2005 6:00 pm 
Beginner
Beginner

Joined: Fri May 13, 2005 11:48 am
Posts: 32
Here is a snippet of my class mapping file.
Code:
<many-to-one name="Sector" class="Sector,MyDll" not-null="true">
    <column name="PrimarySSC"/>
    <column name="Language"/> <!-- Don't save this -->
</many-to-one>
<many-to-one name="Language" column="Language" class="Language,MyDll" not-null="true"/>

Since this isn't a property there is no update="false" option. The language is there to keep track of what language is used in the object and for all related objects. So ideally the language column is shared by the class and its children.

Let me know if you need more information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 11:19 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Ok, another solution: don't map the separate Language property, just declare it like this:

property Language Language
{
get { return Sector.Language; }
}

But this will of course cause Sector to be loaded when accessing the property, I don't know if it matters for you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 11:50 am 
Beginner
Beginner

Joined: Fri May 13, 2005 11:48 am
Posts: 32
sergey,

The object that has a Sector object needs to have the semantic of having a Language object. It is that property that determines all of the other language options for the most part. It seems that I may be unable to use my method with nhibernate. This is a bummer. I will keep thinking about it. Hopefully in the future nhibernate will be able to handle such requests.

dru


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 2:51 pm 
Beginner
Beginner

Joined: Fri May 13, 2005 11:48 am
Posts: 32
hmmm I wonder if there is a way to tell nhibernate if there are repeated columns to collapse them to one. I doubt it as that doesn't make much sense. hmm.....


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