Hi!
I am using JPA over Hibernate and I have a problem with inserting (MySql DB) Entity object with the following inheritance hierarchy:
Code:
@Entity
@Table(name="asset")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="Type", discriminatorType=DiscriminatorType.INTEGER)
public abstract class Asset implements Serializable {
private int id;
private String description;
private boolean isAvailable;
private String name;
...
}
@Entity
@Table(name="vehicle")
@DiscriminatorValue("1")
public class Vehicle extends Asset implements Serializable {
...
}
When calling persist method on EntityManager, the generated sql is:
Code:
Hibernate: insert into asset (Description, IsAvailable, Name) values (?, ?, ?)
Since 'Type' column is NOT NULL, insert fails due to missing parameter.
What am I missing?
Thanks in advance.