-->
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: Many-to-one WITHOUT using primary keys
PostPosted: Fri Jun 18, 2004 5:17 pm 
Newbie

Joined: Wed May 19, 2004 7:39 pm
Posts: 16
Location: Canton, GA
I would like to perform a mapping between an object that contains a collection of files, called Package, and a collection of file objects, call PackageFile. I do not want to use the primary keys for this mapping. Instead I want to use the GUIDs from the object to form the relationship. When I run my test, I get an empty result set.

The reason I'm looking to do this is because these objects are being transferred over a web service, and the guid & guid relationships must remain in tact. However since they are coming across via the web service, they must be INSERTed on the receiving end preferrably using Hibernate's cascade functionality. So I blow away the IDs, keep the GUIDs, and everything inserts as it should.

On the Package side, I have the following snippet in my mapping doc:

Code:
<set name="packageFiles" inverse="true"  >
            <key column="package_guid" foreign-key="guid" />
            <one-to-many class="PackageFile"/>
        </set>


... and on the PackageFile side, I have the following snippet:

Code:
<many-to-one name="aPackage" class="Package" column="package_guid" property-ref="guid" />


So what I would expect would happen is my set of package files would be mapped using Package.guid = FilePackage.package_guid. Hibernate is using the package_guid column from the collection table, but I can see where it's binding a '1' to the query parameter, which means the package id value is being used instead of the package guid value. So in the end, I get:

X 3015 DEBUG [main] net.sf.hibernate.type.LongType - binding '1' to parameter: 1
X 3031 DEBUG [main] net.sf.hibernate.loader.Loader - result set contains (possibly empty) collection: [com.teksouth.jswift.core.domain.Package.packageFiles#1]
X 3031 DEBUG [main] net.sf.hibernate.impl.SessionImpl - uninitialized collection: initializing[code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 3:34 pm 
Newbie

Joined: Wed Sep 22, 2004 12:18 pm
Posts: 14
I have the same issue..did you ever find a way to resolve it?


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.