I have this parent class:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "BSEntity")
@DiscriminatorColumn(name = "resourceType", discriminatorType = DiscriminatorType.STRING, length = 32)
public abstract class BaseEntity {
and the subclass
@Entity
@Table(name = "BSCategory")
@DiscriminatorValue("Category")
public class CategoryEntity extends BaseEntity {
But when I run the program, I get the following error:
2010-06-03 10:13:54,222 [main] WARN (org.hibernate.util.JDBCExceptionReporter:100) - SQL Error: 1364, SQLState: HY000
2010-06-03 10:13:54,222 [main] ERROR (org.hibernate.util.JDBCExceptionReporter:101) - Field 'resourceType' doesn't have a default value
Any thoughts?
Updated: Database is MySQL. I have also changed inheritance strategy to JOINED instead of SINGLE_TABLE. Help
Another Update: I saw the following posting somewhere and it looks very interesting: http://opensource.atlassian.com/projects/hibernate/browse/ANN-140
New Update: If I were to use SecondaryTable approach, how would I proceed then?
Final Update: turns out the @Discriminator thing does not work well with hibernate. I used the @SecondaryTable approach and that took care of this issue for me. Thanks everyone for helping me out!