I am using the table per subclass method. However i am running into a problem. It is reading from the database fine but writing to the database fails , be it insertion, deletion or updation. Hibernate does not throw an exception and tells me that the data is written but when i check the database its not there. Any idea why this might be happening ?
I am using Spring Daos for this. I am pasting the Pojos below
Parent Class
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "PARENT", schema = "TEST")
public class Parent implements java.io.Serializable {
// Fields
private Long parentid;
private String type;
// Constructors
/** default constructor */
public Parent() {
}
/** full constructor */
public Parent(Long id, String type) {
this.parentid = id;
this.type = type;
}
// Property accessors
@Id
@Column(name = "PARENTID", unique = true, nullable = false, precision = 12, scale = 0)
public Long getParentid() {
return this.parentid;
}
public void setParentid(Long id) {
this.parentid = id;
}
@Column(name = "DTYPE", nullable = true, length = 25)
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
}
Child Class Code
Code:
/**
* Child1 entity. @author MyEclipse Persistence Tools
*/
@Entity
@Table(name = "CHILD1", schema = "TEST")
@PrimaryKeyJoinColumn(name="ID", referencedColumnName="PARENTID" )
public class Child1 extends com.sime.test.Parent implements
java.io.Serializable {
// Fields
private String c11;
private String c12;
private String c13;
// Constructors
/** default constructor */
public Child1() {
}
/** full constructor */
public Child1(Long id, String type, String c11, String c12, String c13) {
//this.id = id;
this.c11 = c11;
this.c12 = c12;
this.c13 = c13;
setParentid(id);
setType(type);
}
@Column(name = "C11", length = 25)
public String getC11() {
return this.c11;
}
public void setC11(String c11) {
this.c11 = c11;
}
@Column(name = "C12", length = 25)
public String getC12() {
return this.c12;
}
public void setC12(String c12) {
this.c12 = c12;
}
@Column(name = "C13", length = 25)
public String getC13() {
return this.c13;
}
public void setC13(String c13) {
this.c13 = c13;
}
}