-->
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 one-to-one relation as primitive type
PostPosted: Thu Jun 16, 2011 10:49 am 
Newbie

Joined: Thu Jun 16, 2011 10:37 am
Posts: 1
Hi,
the company I work for has a Hibernate mappings for entities model - this was created from scratch, well designed and has all correct, working mappings - it works with Derby database.
Now we want to use the created entities and create just mapping files to be able to read legacy data from another database, which has slightly different schema, but similar enough to try to map it using our Java entity classes.
Unfortunately there are a lot of situations in that legacy DB where value - represented in new schema as just e.g. String - is kept in separate table and referenced via ID. The following example will put more light on this configuration:

TableA - id, name, description, tableB_id
TableB - id, name

whereas Java classes are:
EntityA - id, name, description, nameFromEntityB
EntityB - shouldn't really exists, since it is not needed

So in order to represent EntityA in full, we would have to load just the name from TableB using TableA.tableB_id = TableB.id relation, but what actually interests us from TableB is just the name, and it should be stored in a String field (nameFromEntityB) in EntityA class (the new schema and mappings got rid of this unnecessary TableB and keep the name as a string value in TableA).

Is it possible to construct HBM mapping file to achieve this?

Thank you in advance for any help.


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.