Uploaded image for project: 'Hibernate ORM'
  1. HHH-3733

Introduce an annotation to disable ad-hoc null semantic of Hibernate components


    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Labels:
    • Last commented by a user?:
    • Sprint:


      see http://forums.hibernate.org/viewtopic.php?t=993972

      For the model

      public class Person {
      private Address name = new Address();
      @Embedded Address getAddress() {}

      public class Address {
      public String getCity() {}
      public String getStreet() {}

      the following xhtml excerpt causes NPE constantly when editing a person which address properties hasn't been filled in yet

      <h:inputText value="#


      " />

      I suggest introducing an annotation @Static which could be applied to Address class and lead to disabling null ad-hoc semantic on its instances.

      For some environments such as user interface this may be considered as the default behavior. I suggest introducing an Hibernate configuration parameter which would switch off the semantic.

      I would propose to consider embeddable classes as static mixins from OO design, not as just limited entities without identity. This point of view explains that embedded instance is a part of entity so it's lifecycle is the same as the entity's lifecycle. Thus constant presence of embeddable instance (property is never null) is the default behavior. Thus configuration parameter is "must have", not the thing which is "nice to have".

      From the other hand null ad-hoc semantic is like dynamic mixins. So it would be nice to have a @Dynamic annotation to force this semantic for some components.


          Issue links



              • Votes:
                4 Vote for this issue
                7 Start watching this issue


                • Created: