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.
|