diff --git a/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/AnnotationEntity.java b/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/AnnotationEntity.java new file mode 100644 index 0000000000..a675e87ead --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/AnnotationEntity.java @@ -0,0 +1,25 @@ +package org.hibernate.boot.model.source.internal.hbm; + +import javax.persistence.*; + +@Entity +public class AnnotationEntity { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "annotationentity_id_seq") + @SequenceGenerator( + name = "annotationentity_id_seq", + sequenceName = "annotationentity_id_seq" + ) + private Long _id; + + /** + * Get the identifier. + * + * @return the id. + */ + public Long getId() + { + return _id; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/HBMEntity.java b/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/HBMEntity.java new file mode 100644 index 0000000000..40546468cd --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/HBMEntity.java @@ -0,0 +1,23 @@ +package org.hibernate.boot.model.source.internal.hbm; + +public class HBMEntity { + + private long _id; + private AnnotationEntity _association; + + public long getId() { + return _id; + } + + public void setId(long id) { + _id = id; + } + + public AnnotationEntity getAssociation() { + return _association; + } + + public void setAssociation(AnnotationEntity association) { + _association = association; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/HBMManyToOneAnnotationMissingPrimaryKeyTest.java b/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/HBMManyToOneAnnotationMissingPrimaryKeyTest.java new file mode 100644 index 0000000000..d194e07f33 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/boot/model/source/internal/hbm/HBMManyToOneAnnotationMissingPrimaryKeyTest.java @@ -0,0 +1,41 @@ +package org.hibernate.boot.model.source.internal.hbm; + +import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; +import org.junit.Assert; +import org.junit.Test; + +/** + * https://hibernate.atlassian.net/browse/HHH-11502 + * + * @author Russ Tennant (russ@venturetech.net) + */ +public class HBMManyToOneAnnotationMissingPrimaryKeyTest extends BaseNonConfigCoreFunctionalTestCase +{ + @Override + protected Class[] getAnnotatedClasses() { + return new Class[]{ + AnnotationEntity.class + }; + } + + @Override + protected String[] getMappings() { + return new String[]{ + "HBMEntity.hbm.xml" + }; + } + + @Override + protected String getBaseForMappings() { + return "/org/hibernate/boot/model/source/internal/hbm/"; + } + + /** + * Test to trigger the NullPointerException in the ModelBinder. + * @throws Exception on error. + */ + @Test + public void hhh11502() throws Exception { + Assert.assertTrue(true); + } +} diff --git a/hibernate-core/src/test/resources/org/hibernate/boot/model/source/internal/hbm/HBMEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/boot/model/source/internal/hbm/HBMEntity.hbm.xml new file mode 100644 index 0000000000..4ae7137180 --- /dev/null +++ b/hibernate-core/src/test/resources/org/hibernate/boot/model/source/internal/hbm/HBMEntity.hbm.xml @@ -0,0 +1,16 @@ + + + + + + + + hbmentity_id_sequence + + + + + + \ No newline at end of file