-->
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.  [ 2 posts ] 
Author Message
 Post subject: Newbie question: mapping composite object?
PostPosted: Thu Apr 26, 2007 9:01 am 
Regular
Regular

Joined: Tue Apr 10, 2007 10:02 am
Posts: 56
In my application design I have a table to hold entity instances and a separate table to hold the entity status, like...

Code:
Entity
-------
EntityID        int
EntityName   varchar(50)
EntityAlias     varchar(20)

EntityStatus
------------
StatusID                      int
EntityID                       int
StatusDate                  timestamp
StatusDescription          varchar(50)
StatusChangeReason     varchar(200)

public class Entity {
   private int fID;
   private String fName;
   private String fAlias;
   ...
   ...
}

public class EntityStatus {
   private int fID;
   private int fEntityID
   private Date fDate
   private String fDesc;
   private String fReason;
   ...
   ...
}


Hence, a single instance in the 'Entity' table can have multiple data instances in the 'EntityStatus' table.

I want to create a composite object that represents the entity plus its latest status like...

Code:
public class EntityInfo extends Entity {
   private EntityStatus  fLatestStatus;
   ...
   ...
}


The latest status field would represent the entry in the 'EntityStatus' table with the most recent 'StatusDate' field.

How would I go about mapping the 'fLatestStatus' object field?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 1:35 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Seems like you status is a component inside your class. Maybe see component mapping: http://www.hibernate.org/hib_docs/v3/re ... components

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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