-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping Roles instead of inheritance
PostPosted: Tue Jun 15, 2004 10:08 am 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Hi people. Firstly, I want to thank you people for this amazing work on hibenate. It's really COOL.
Well I'm Newbie. I'm trying to find a good example (or advise) of the old role problem mapping something like this:

Person -> one-to-many -> Role -> many-to-one -> RoleType
idperson (pk) idRole (pk) roleType
name fkperson
fkroletype
roleInformation
...
This is my relational database and my trivial mapping was that generated by "hibernate synchronizer".
What I want to do is create logical one-to-one relations btw Person and role representing the RoleType. My motivation is that I really dislike doing something like

Person p =...
fatherRole =...query(p.getRoles(),"Where fkroletype='father'")
print(fatherRole.getRoleInformation);

I want to code thos w/o sql (if it's possible :). Something like
Person p=...
fatherRole = p.getAsFather();
//fatherRole will be null if he is not a father

well, Is it possible to be done?
I see that I can put where clauses in the mapping for sets, but it will result in something odd like:

p.getFatherRole()[0]

Also i give up inheritance solution since conceptualy, it's more like an interface. I don't want to code each possible combination btw roletype and person as a class. And i can't use where clauses in subclasses anyway. But I can afford to code method accessors (one-to-one).

By the way, any links to examples (not the usual ones in the source distribution, that I got already) will be apreciated. The same for any new tutorials or blogs.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.