persistence@glassfish.java.net

Recommendation - on Id/Embedable ID classes

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Thu, 17 Jan 2008 10:27:00 +0000

 
Hello everyone,
I have an entity:
public class Iteamdetailsent implements Serializable{ // @Id @Column(name="ITMID", nullable=false, length=8) private String itmid; @Column(name="ITMNAME", nullable=true, length=40) private String itmname; @Column(name="DESCRIPTION", nullable=true, length=200)
..................}
OUt of this entity, I would like to create other entities (Collectpointitems and Self_serveent) which would have the Id 'String itmid' from Iteamdetailsent as a foriegn key. reason why is
Collectionpointent and Self_serveent are the only items within theIteamdetailsent entity which requires extra attributes. e.g.
@Entity_at_Table(name="COLLECTPOINTITEMS")
public class Collectpointitems implements java.io.Serializable{
 
 @OneToOne() @JoinColumn(name="ITMID") private Iteamdetailsent iteamdetailsent; @Column(name="LOCATION", nullable=true, length=20) private String location;
..................}
Now when I try to compile build or deploy it, it's no surprising, it ask for an Id
And as you can see I do not need the it within these entities as I amtrying to create it as if Iteamdetailsent is the parent class where Collectpointitems is developed from it; because, Collectpointitems whouldhave all the attributes of Iteamdetailsent and it's own attributes.
To explain myself further, the Collectpointitems and Self_serent areall items kept in a warehouse. And as a result, customers requires thelocation to pick these items up. Whereas, all the other items as storewithin the shop floor. and do not need the Location attribute.
My question is should I include the location attribute in Iteamdetailsentso that there would be no need to create the other entities (Collectpointitems)i.e:
public class Iteamdetailsent implements Serializable{ // @Id @Column(name="ITMID", nullable=false, length=8) private String itmid; @Column(name="ITMNAME", nullable=true, length=40) private String itmname; @Column(name="DESCRIPTION", nullable=true, length=200) @Column(name="LOCATION", nullable=true, length=20) private String location;
 
..................}
Or should I separate them? And if so, what do I do aboutthe ID issue? Should I just generate ID when data is entered,but make not use of it? What should I do?
 
eve
 
_________________________________________________________________
Share what Santa brought you
https://www.mycooluncool.com