-->
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.  [ 5 posts ] 
Author Message
 Post subject: Composite Keys and Null values
PostPosted: Thu Sep 21, 2006 6:00 pm 
Newbie

Joined: Thu Sep 21, 2006 5:49 pm
Posts: 3
Hi all,

I am running into a problem when using a composite key on a couple of tables.

First off, I have a "Container" object that has the following in its definition:
......
<class name="Ryder.Arsenal.LLM.LPS.Container, Ryder.Arsenal.LLM" table="Lps_Container">
<composite-id>
<key-many-to-one name="Account" column="AcctOrg" />
<key-property name="ContainerId" column="ContainerId" type="string" length="32" />
</composite-id>
<property name="Description" column="Descr" />
<property name="Category" column="Category" />
......
the container class is implementing "serializable" and is also overriding both Equals and GetHashCode

now, I have a "Packaging" object that
......
<many-to-one name="Container" insert="false" update="false" cascade="none" class="Ryder.Arsenal.LLM.LPS.Container, Ryder.Arsenal.LLM">
<column name="AcctOrg" />
<column name="ContainerId" />
</many-to-one>
......

Each packaging object refers to a row in a packaging table. The problem I am running into is this:

AcctOrg will always be populated in a package row, but ContainerId might not be because the package might not have a container associated with it. If I do have a containerId setup, this works fine, but when ContainerId is null I am getting an exception saying "No row with the given identifier exists", which I understand why, but what I want to happen is it just ignores it and goes on its merry way.

So, is there a way to set this up (either in the XML or in the overridden methods) so that it recognizes that when ContainerId is null that there is no container to fetch for it? Is there a way to make it setup the composite key to be null if one of those properties of the key is null?

Thanks in advance!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 22, 2006 1:27 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It appears to be a bug, please report it to JIRA, but can you first show the relevant logs?

Also, I wonder how you have managed to define a primary key containing a nullable column, since most databases don't allow this.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 22, 2006 8:30 am 
Newbie

Joined: Thu Sep 21, 2006 5:49 pm
Posts: 3
The only place that the containerId is null is in the packaging table. The container table cannot have a row w/o a container ID. Just to clarify more:

Packaging Table
-------------------
PackagingNo (int32) (PK)
AcctOrg (String)
ContainerId (String)
......

Container Table
-------------------
ContainerId (String)
AcctOrg(String) (this + above creates the composite key)
......

So, the only place that containerId is null is in the packaging table.

Thanks for the help!!!

NOTE:
The log entries I have are REALLY long. What is the best way to go about showing them on the forum, or should I just be using them when/if I submit a bug.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 12:33 pm 
Newbie

Joined: Thu Sep 21, 2006 5:49 pm
Posts: 3
I filed a bug on this issue like you said: http://jira.nhibernate.org/browse/NH-721


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 1:20 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Ahh, this is what you meant... I didn't understand you correctly at first.

1.2.0.Beta1 introduces not-found="ignore" attribute which you can try using in <many-to-one>, but if you are stuck on 1.0.1 then I'm afraid nothing can be done.


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