-->
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: Different mapping for the same entity
PostPosted: Thu Nov 19, 2009 12:50 pm 
Newbie

Joined: Wed May 24, 2006 9:45 pm
Posts: 10
I was wondering if it's possible to do the following mapping:
Take a class/table "Person" and a class/table "Asset" (3M share, Coca-Cola shares, Treasure bonds, Central Park Apartment, etc). And each "Asset" have an "AssetCategory" (stocks, buildings, bonds, etc). So, "3M" shares is of type "Stocks".

Take this as a Many-to-Many, once a person can invest in several assets. To map this we have an Person_Assets table.
No problem for me here to map this as a M2M relationship inside a property named "allAssets".

But I was thinking if it's possible to add a propery named "cars", in the "Person", that maps all records in "person_assets" table, with type_id = X. And I also would have a property named "realEstates" that maps all records in "person_assets" table, with the type_id = Y.

In fact, "allAssets", "cars" and "realEstates" properties should map the same table, but "cars" and "realEstates" would be a subset of "allAssets". I think this would make my "API" a little bit simpler, once "cars" and "realEstates" are more often refered and I don't want to pass thru all assets only to check the type of each one...

Is it possible? What should I google/read to do this?
Is it correct/recommended?

Thank you all.


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.