-->
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.  [ 4 posts ] 
Author Message
 Post subject: Map implicit relationship?
PostPosted: Thu Aug 28, 2003 8:46 pm 
Newbie

Joined: Thu Aug 28, 2003 8:32 pm
Posts: 7
I'm mapping a legacy DB which has an implicit relationship
between two tables. This can of course be handled at the application
level but I would love to create a hibernate mapping if possible.

Its a many-to-one or zero association. Let's say from M to OZ.
OZs primary key is a value, say REF in M that will never be null.
The important point is that there isn't an OZ for every REF in M.

I have been able to map it fine using many-to-one except that when
OZ doesn't exist for a REF, hibernate tries to hydrate the OZ anyway
and I get a NullPointerException (as expected).

Is there anyway to map this that hibernate won't freak out?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 9:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use a UserType.


Top
 Profile  
 
 Post subject: Use a UserType
PostPosted: Fri Aug 29, 2003 11:50 pm 
Newbie

Joined: Thu Aug 28, 2003 8:32 pm
Posts: 7
gavin wrote:
Use a UserType.



If I created a type, what would the mapping I create
be?


Top
 Profile  
 
 Post subject: Use a UserType
PostPosted: Tue Sep 02, 2003 12:43 pm 
Newbie

Joined: Thu Aug 28, 2003 8:32 pm
Posts: 7
I've been looking hard at the UserType class, CompositeUserType
class and tests that implement them but I just don't see how it solves
my problem. It looks like I could create a collection of some type
in M (from my example above) using a custom type but I don't see
how to map it or create it so that M doesn't end up with a collection
of all OZs. First of all, there will only be one OZ for each M if there
is one at all. A collection is impractical. In our case there are roughly
a half million OZs and that number will probably double or triple in
a year or so, and keep growing after that. I dont' see how to create a UserType and map it such that that there is only one of my custom type (representing an OZ) based on the OZ key in M.


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