-->
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: Lookup table mapping using JPA
PostPosted: Mon Mar 22, 2010 6:04 pm 
Newbie

Joined: Mon Mar 22, 2010 5:33 pm
Posts: 5
Hi All,

I have two tables one table is the ApplicationTBL and another table is the AppStatusTBL.

ApplicationTBL is the table which stores the information for each online application it has appID(PK),firstName,lastName,appstatusID

the appstatusID is the foreign key from AppStatusTBL which has the following columns appstatusID(PK), statusName, statusDesc.

The AppStatusTBL is the lookup table only. I dont want anybody to update and two additional tables are also using this table. All I want is if I query the ApplicationTBL i shoudl be able to access the AppStatusTBL row belonging to the appstatusID.

I am stuck here, Please help me on how should I configure the relationships between these two tables e.g. using @onetomay or @ manytoone relations or something like that.

Here is the code:

ApplicationTBL:

@Entity
@Table(name = "applicationtbl")
public class ApplicationTBL implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(unique = true, nullable = false)
private int appID;

@Column(nullable = false, length = 40)
private String firstName;

@Column(nullable = false, length = 40)
private String lastName;

@Column(nullable = false)
private int appstatusID;

public ApplicationTBL() {
}

// getter and setter method

}

AppStatusTBL

@Entity
@Table(name="appstatustbl")
public class AppStatusTBL implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(unique=true, nullable=false)
private int appstatusID;

@Column(nullable=false, length=40)
private String statusName;

@Column(nullable=false, length=100)
private String statusDesc;

public AppStatusTBL() {
}

//getter and setter method
}

I just have to define the relations between the ApplicationTBL table and AppStatusTBL table. Not able to decide what to do.


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.