@Basic(optional) not overridden when using an @Embeddable type in Hibernate

Solution In Progress - Updated -

Issue

  • An entity using an embeddable attempts to override the @Basic(optional = false) setting

    @Embeddable
    public class MyEmbeddable ... {
        @Basic(optional = false)
        @Column(nullable = false)
        private String someProperty;
        ...
    }
    
    @Entity
    public class MyEntity ... {
        @Embedded
        @AttributeOverrides({
            @AttributeOverride(name = "someProperty", column = @Column(nullable = true)))
        })
        private MyEmbeddable embeddedType;
        ...
    }
    
  • The generated DDL marks the database column as non-null allowed
  • No warnings are logged and no exceptions are raised during configuration

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6
  • Hibernate 4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.