0 Replies Latest reply on Aug 14, 2007 5:54 AM by asaf sh

    Hibernate with Oracle10g, Inheritance issue

    asaf sh Expert


      I have an abstract class (Base) that looks as follows:

      class abstract Base {
       some properties here

      Then I have two classes that inherit from this base class that looks like:
      public class YBase extends Baseimplements Serializable {

      and another one as:

      public class ZBase extends Baseimplements Serializable {
       private SomeEntity someEntity;
       @JoinColumn(name="SOME_ENTITY_ID", nullable=false, unique=false)
       public SomeEntity getSomeEntity() {
       return someEntity;

      With Mysql, When I persist YBase entities, everything work fine, and I see under the 'SOME_ENTITY_ID' column a value '0',

      I assume hibernate set a default value as 0 automatically although the column definition in msql is set as 'NOT_NULL' without a default value.

      In oracle, I get an exception as follows:
      Caused by: java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into ("IDM_PREPRD_REPOSITORY"."MY_TABLE"."SOME_ENTITY_ID")

      and in the database I can see that the column is set as NOT NULL, but a default value is not set when persisting YBASE entities which has no relationship with the SomeEntity entity,

      Any idea?
      there's a way to fix this issue except annotating the 'getSomeEntity' as optional?