I'm hitting 'org.hibernate.AnnotationException: Mixing nullable and non nullable columns in a property is not allowed' when using hibernate generated entities

Solution Verified - Updated -

Issue

  • I'm generating entities from a table having a primary key based on many columns. Once hibernate starts with such generated Entities, following error is raised

    org.hibernate.AnnotationException: Mixing nullable and non nullable columns in a property is not allowed: org.domain.project.entity.Employeetask
     at org.hibernate.cfg.Ejb3Column.checkPropertyConsistency(Ejb3Column.java:414)
     at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:1981)
     at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1361)
     at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
     at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
     at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
    

Environment

  • Hibernate all versions

  • Java Persistence API (JPA) 1.0

  • Generated Entities with composite-ids (@EmbeddedId)

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.