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

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

    Details

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

      Description

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

      For the model

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

      @Embeddable
      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="#

      {person.address.city}

      " />

      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.

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: