I have two entity class having relationship one to one. while fetching data, I am getting below error.
Note: In "EPLAN_ELEMENT_DEFINITION" table primary key is "ELEMENT_DEFINITION_ID" and in "EPLAN_INPUT_ELEMENT" table foreign key is "INPUT_ELEMENT_ID". Basically name of keys are different in both tables.
**************** ERR****************
08:50:52.536 DEBUG [http-bio-8080-exec-8][SqlExceptionHelper] could not extract ResultSet [n/a] java.sql.SQLSyntaxErrorException: ORA-00904: "ELEMENTDEF0_"."INPUTELEMENT": invalid identifier
**************** ERR****************
Source Code:-
ElementDefinition:
Code:
@Entity
@Table(name = "EPLAN_ELEMENT_DEFINITION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
public abstract class ElementDefinition extends au.gov.nsw.lpi.bds.eplan.elements.ElementDefinition
{
@Id
@Column(name = "ELEMENT_DEFINITION_ID")
private Long id;
@Column(name = "NAME")
@Enumerated(EnumType.STRING)
private ElementName name;
@Column(name = "DESCRIPTION")
private String description;
public Long getId() {
return id;
}
public String getDescription() {
return description;
}
private InputElement inputElement;
@OneToOne(mappedBy = "elementDefinition")
public InputElement getInputElement() {
return inputElement;
}
public void setInputElement(InputElement inputElement) {
this.inputElement = inputElement;
}
@Override
public ElementName name() {
return getName();
}
public ElementName getName() {
return name;
}
}
Input Element:
Code:
@Entity
@Table(name = "EPLAN_INPUT_ELEMENT")
public class InputElement implements Serializable
{
private ElementDefinition elementDefinition;
@Id
@OneToOne
@JoinColumn(name="INPUT_ELEMENT_ID", referencedColumnName="ELEMENT_DEFINITION_ID")
public ElementDefinition getElementDefinition() {
return elementDefinition;
}
public void setElementDefinition(ElementDefinition elementDefinition) {
this.elementDefinition = elementDefinition;
}
public void setDefaultMandatoryInd(String defaultMandatoryInd) {
this.defaultMandatoryInd = defaultMandatoryInd;
}
}