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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content