-->
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: one-to-one troubles
PostPosted: Fri Sep 26, 2003 4:17 am 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
reading the docs (pasted below) it says that the pk needs to be the same on both objects, i have a situation where I need to have just one object returned
but they wont both have the same pk.

i want to have a user.getGallery() but the Gallery object has a different pk that the User object does so I cant use this one-to-one and it looks like I need to use a one-to-many holding just one object , is there anyway around this?

i need the tables look like this:
User table has columns, id, name, galleryId
Gallery table has columns id, name

i basically need a Gallery (which contains a set of galleryImages) that I can attached to anything like say an article or user or event

I need a user.getGallery but dont need a gallery.getUser etc

hope you guys can understand my question, its late :)

4.1.11. one-to-one

A one-to-one association to another persistent class is declared using a one-to-one element.

One-to-one associations don't need an extra table column; if two rows are related by a one-to-one association then the two table rows share the same primary key value. So if you want two objects to be related by a one-to-one association, you must make sure that they are assigned the same identifier value!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 4:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate 2.1 supports this.


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.