0 Replies Latest reply on Jan 11, 2006 6:15 AM by obondarenko

    InheritanceType.SINGLE_TABLE and NOT NULL field constraints

    obondarenko

      Hello everybody!
      Using InheritanceType.SINGLE_TABLE means that we can't use @Column(nullable = false) in any child entity inherited from one parent? Isn't it?

      In that case when hibernate performs SQL insert operation for some child entity database not null constraint is violated because all fields that belong to other child entities (inherited from one parent) are initialized to null.

      Surely, the problem can be solved by JOINTED_TABLE strategy, but what for SINGLE_TABLE was developed? What if I need SINGLE_TABLE for performance reasons?

      A question to jboss officials - how do you paln to handle this UC?

      I see some walkarounds, but I don't like them:
      - disable db constraints by hands
      - use columnDefinition attribute of the @Column to specify default values (I dont like this because of native SQL DDL neede to be embeded in the Entity)

      Any comments?