-->
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.  [ 8 posts ] 
Author Message
 Post subject: Many-to-One mapping problem
PostPosted: Tue Jun 22, 2004 11:45 am 
Newbie

Joined: Wed May 19, 2004 7:39 pm
Posts: 16
Location: Canton, GA
There doesn't appear to be a way to map Many-to-One without using primary keys. I have GUIDs that I need to map in a relationship structure, but they are not my primary keys.

The structure is very straight forward. I have an object called Package that contains a collection of PackageFile objects. Both of those objects have an id (Long) and a guid (String).

Those objects map to package and package_file tables. There is an FK in package_file to package on a column named package_guid.

I want to have a hibernate mapped collection where I can call getFiles() that will return a collection of PackageFile objects based on the Package.guid = PackageFile.package_guid relationship.

I can post some code / mapping file if you need them, but that's pretty much it. Many-to-one has a <key> tag to specify the column to use in the foreign table when you do not want to use the primary key. However there doesn't seem to be a way in hibernate to specify a non-primary key column to use in the parent table.

Can someone please at least confirm if this is doable or not? Am I missing something here?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 11:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you're posting many times the same post....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Of course...
PostPosted: Tue Jun 22, 2004 12:12 pm 
Newbie

Joined: Wed May 19, 2004 7:39 pm
Posts: 16
Location: Canton, GA
... I know. I'm not getting a reply. It would seem that after a day or so when you're not on the top 10, then no one looks at these anymore.

I'm in a criticle path situation with an ORM that seems not quite be cutting it. This is my only means of finding a solution other than coding a work around for every element we send across a web service.

I'm simply asking if anyone can confirm one way or another whether or not I can use non-primary keys to do this. If you're telling me to stop posting because no one knows, then let me know, and I won't post another message.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:18 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
I'm simply asking if anyone can confirm one way or another whether or not I can use non-primary keys to do this. If you're telling me to stop posting because no one knows, then let me know, and I won't post another message.


This is not how forums work, you know. People might just be too busy with other things. Just because no one answers doesn't mean no one can answer your question, it might simply take too much time at the moment.

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


Top
 Profile  
 
 Post subject: Understandable
PostPosted: Tue Jun 22, 2004 12:28 pm 
Newbie

Joined: Wed May 19, 2004 7:39 pm
Posts: 16
Location: Canton, GA
My appologies to all about how I'm using the forums. I'm just looking for an answer.

Overall Hibernate is pretty cool, but I think we're a special use case where we send related data across a web service using Hibernate at both ends. It just seems that Hibernate is not suited to this situation. So switching to another ORM like JDO might our best option.

I know the forums are free and developers like me are spending time helping when they can. Thanks to everyone that has helped in the past...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(1) <many-to-one property-ref="..."/>
(2) If you write questions more clearly so that people can understand you, they are more likely to answer
(3) threats to stop using Hibernate are always amusing (oh no, think of all that lost revenue, how will I eat?!)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:56 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
do you really think JDO or another ORM will give you more flexibility....
be serious if you change your tools everytimes you don't fing the solution by your own.... you'll never finish a projet.

To be more cool, Christian said
Quote:
People might just be too busy with other things.


and that's exactly why i wasn't able to help you soon yesterday, now gavin gave you you the tip, just be patient next time.


Peace,

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Tue Jun 22, 2004 2:31 pm 
Newbie

Joined: Wed May 19, 2004 7:39 pm
Posts: 16
Location: Canton, GA
Gavin:
(1) Ok, I get a dink award for this one... my problem was for one-to-many. I messed up and put many-to-one, although I was looking for a property-ref on the one-to-many def, but I didn't see it.
(2) Was it seriously unclear? Other than the fact I completely used the wrong tag, it made perfect sense. lol
(3) I wasn't threatening. I know you couldn't care less about "1" guy somewhere on the net (and boy does it show), and that wasn't why I made the comment. I was somewhat at a loss, and still am at the moment. On the flip side, I'm also hoping that the Advanced Mapping chapter of your book Hibernate in Action would help clear some of this up too. So crank it out. :)


Anthony, another ORM or JDO implementation might or might not do what I need. I agree though that switching in never a good idea, but sometimes you have to do what you have to do. Again this might just be a special case where Hibernate doesn't work out for us, and I can obviously tell that if we were using Hibernate in a standard persistence fashion instead of passing related data across web services for persistence, then it would be cat's meow.

Also I figured you were busy which is why I said, "I know the forums are free and developers like me are spending time helping when they can." It's not like your obligated to answer posts... I was just hoping someone else would see it and shed some light on the subject.

Peace


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