Composite Key Question
msly Sep 8, 2005 2:19 PMI have a table that has a composite key. One value is from the table and one is a foreign key in another table.
Here is the class that I am trying to anotate:
/***********************************************************************
* Module: ActionStatus.java
* Author: mslyter
* Purpose: Defines the Class ActionStatus
***********************************************************************/
package gov.utah.laborcommission.safety.entities;
import java.io.Serializable;
import javax.persistence.*;
@Entity(access = AccessType.FIELD)
@Table(name = "ACTION_STATUS")
public class ActionStatus implements Serializable{
private SystemType systemType;
private String actionStatus;
private String actionStatusDesc;
private String activeIndicator;
@ManyToOne
@JoinColumn(name="systemType", insertable=false, updatable=false)
public SystemType getSystemType() {
return systemType;
}
public void setSystemType(SystemType systemType) {
this.systemType = systemType;
}
@Id(generate = GeneratorType.NONE)
@Column(name="Action_Status")
public String getActionStatus() {
return actionStatus;
}
public void setActionStatus(String actionStatus) {
this.actionStatus = actionStatus;
}
@Column(name="Action_Status_Desc")
public String getActionStatusDesc() {
return actionStatusDesc;
}
public void setActionStatusDesc(String actionStatusDesc) {
this.actionStatusDesc = actionStatusDesc;
}
@Column(name="Active_Indicator")
public String getActiveIndicator() {
return activeIndicator;
}
public void setActiveIndicator(String activeIndicator) {
this.activeIndicator = activeIndicator;
}
}The class contains the field that the foreign/primary key is in:
/***********************************************************************
* Module: SystemType.java
* Author: mslyter
* Purpose: Defines the Class SystemType
***********************************************************************/
package gov.utah.laborcommission.safety.entities;
import java.io.Serializable;
import javax.persistence.*;
import java.util.*;
@Entity
@Table(name = "SYSTEM_TYPE")
public class SystemType implements Serializable{
private String systemType;
private String systemTypeDesc;
private String activeIndicator;
private String wpExePath;
private String documentTemplatePath;
private String emailTemplatePath;
private String documentSavePath;
private LcEntity supportEntityID;
private LcEntity contactEntityID;
private Date lastImportFileDate;
private String importPath;
private String exportPath;
private String logFilePath;
private String wpDdeCommand;
public SystemType(){}
public SystemType(String systemType,
String systemTypeDesc,
String activeIndicator,
String wpExePath,
String documentTemplatePath,
String emailTemplatePath,
String documentSavePath,
LcEntity supportEntityID,
LcEntity contactEntityID,
Date lastImportFileDate,
String importPath,
String exportPath,
String logFilePath,
String wpDdeCommand) {
this.systemType = systemType;
this.systemTypeDesc = systemTypeDesc;
this.activeIndicator = activeIndicator;
this.wpExePath = wpExePath;
this.documentTemplatePath = documentTemplatePath;
this.emailTemplatePath = emailTemplatePath;
this.documentSavePath = documentSavePath;
this.supportEntityID = supportEntityID;
this.contactEntityID = contactEntityID;
this.lastImportFileDate = lastImportFileDate;
this.importPath = importPath;
this.exportPath = exportPath;
this.logFilePath = logFilePath;
this.wpDdeCommand = wpDdeCommand;
}
@Id
@Column(name="System_Type")
public String getSystemType() {
return systemType;
}
public void setSystemType(String systemType) {
this.systemType = systemType;
}
@ManyToOne(optional=false)
@JoinColumn(name="Entity_ID")
public LcEntity getContactEntityID() {
return contactEntityID;
}
public void setContactEntityID(LcEntity contactEntityID) {
this.contactEntityID = contactEntityID;
}
@ManyToOne(optional=false)
@JoinColumn(name="Entity_ID")
public LcEntity getSupportEntityID() {
return supportEntityID;
}
public void setSupportEntityID(LcEntity supportEntityID) {
this.supportEntityID = supportEntityID;
}
@Column(name="Active_Indicator")
public String getActiveIndicator() {
return activeIndicator;
}
public void setActiveIndicator(String activeIndicator) {
this.activeIndicator = activeIndicator;
}
@Column(name="Document_Save_Path")
public String getDocumentSavePath() {
return documentSavePath;
}
public void setDocumentSavePath(String documentSavePath) {
this.documentSavePath = documentSavePath;
}
@Column(name="Document_Template_Path")
public String getDocumentTemplatePath() {
return documentTemplatePath;
}
public void setDocumentTemplatePath(String documentTemplatePath) {
this.documentTemplatePath = documentTemplatePath;
}
@Column(name="Email_Template_Path")
public String getEmailTemplatePath() {
return emailTemplatePath;
}
public void setEmailTemplatePath(String emailTemplatePath) {
this.emailTemplatePath = emailTemplatePath;
}
@Column(name="Export_Path")
public String getExportPath() {
return exportPath;
}
public void setExportPath(String exportPath) {
this.exportPath = exportPath;
}
@Column(name="Import_Path")
public String getImportPath() {
return importPath;
}
public void setImportPath(String importPath) {
this.importPath = importPath;
}
@Column(name="Last_Import_File_Date")
public Date getLastImportFileDate() {
return lastImportFileDate;
}
public void setLastImportFileDate(Date lastImportFileDate) {
this.lastImportFileDate = lastImportFileDate;
}
@Column(name="Log_File_Path")
public String getLogFilePath() {
return logFilePath;
}
public void setLogFilePath(String logFilePath) {
this.logFilePath = logFilePath;
}
@Column(name="System_Type_Desc")
public String getSystemTypeDesc() {
return systemTypeDesc;
}
public void setSystemTypeDesc(String systemTypeDesc) {
this.systemTypeDesc = systemTypeDesc;
}
@Column(name="WP_DDE_Command")
public String getWpDdeCommand() {
return wpDdeCommand;
}
public void setWpDdeCommand(String wpDdeCommand) {
this.wpDdeCommand = wpDdeCommand;
}
@Column(name="WP_Exe_Path")
public String getWpExePath() {
return wpExePath;
}
public void setWpExePath(String wpExePath) {
this.wpExePath = wpExePath;
}
}How do I anotate this correctly. I haven't seen an example of anything like this.
Any Help would be appreciated,
Mike