Hi guys
I am using hibernate 3.2 GA as my persistance provider with mysql 5 as my database.
I am trying to map an object model to the database model (or may be vice versa.)
I have an Loan base object with its own Loan table. Then i have an LoanOptionARM object that extends Loan object and a couple of concrete child loan objects, let show my entities.
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name="LOAN")
@DiscriminatorColumn(
name="LOAN_PRODUCT_NAME",
discriminatorType=DiscriminatorType.STRING
)
public class Loan implements java.io.Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="LOAN_IDENTIFIER")
public int getId() {
return id;
}
@Column(name="LOAN_PRODUCT_NAME")
public String getLoanProductName() {
return loanProductName;
}
}
@Entity
@Table(name="LOAN_OPTION_ARM")
public abstract class LoanOptionARM
extends Loan
implements java.io.Serializable {
}
@Entity
@Table(name="LOAN_OPTION_ARM")
@DiscriminatorValue(value="CF2L")
public class LoanOptionARMCF2L extends LoanOptionARM {
}
i have left the rest of the code in the entities for obvious reasons. The problem that I am facing is that hibernate is generating an extra insert query for Loan_Option_Arm table as I can see in the hibernate log.
Code:
Hibernate: insert into LOAN (LOAN_PRODUCT_TYPE_ID, LOAN_PRODUCT_NAME) values (?, ?)
Hibernate: insert into LOAN_OPTION_ARM (colmuns) values (values)
Hibernate: insert into LOAN_OPTION_ARM (LOAN_IDENTIFIER) values (?)
The second query inserts the LOAN_OPTION_ARM data correctly but I have no idea why the third query for LOAN_OPTION_ARM is being generated.
Please help me out here.[/code]