-->
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: Single class needs to be mapped to two tables
PostPosted: Mon Sep 19, 2011 11:51 am 
Newbie

Joined: Mon Sep 19, 2011 11:32 am
Posts: 1
I have a class CTMEntity which have a composite id with two fields/columns (ctmEntityId and ctmEntitySys). This class will have fields coming from two tables (say ctmentity, ctmstatus). ctmstatus table also have the same composite id (ctmEntityId and ctmEntitySys) with one-to-one relation with ctmentity. For good reasons, we can not merge the two tables. And also I have to keep CTMEntity as a flat object, that means, CTMEntity can not have a object reference of object CTMStatus. It rather has to have fields from CTMStatus. So, I can not create an object CTMStatus.
Here is sample of the class.

public class CtmEntity {

private int ctmEntityId;
private String ctmEntitySys;
private ..............
private ..............
private ..............

//fields coming fom ctmstatus table, for same ctmEntityId,ctmEntitySys
private int statusId;
private String statusCatgy;
private String statusDesc;
private ..............
private ..............

}

Please suggest me, how should I create my mapping to have fields populated from two tables? I saw join, but as per my understanding join does not work on composite key. Please advice asap.

Thanks
Abhishek


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.