Skip to content

Commit

Permalink
Test case for HHH-11502
Browse files Browse the repository at this point in the history
(cherry picked from commit 8d726a3)
  • Loading branch information
proteus-russ authored and gbadner committed Jun 14, 2017
1 parent 79c6c16 commit f1fa8bd
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
@@ -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;
}
}
@@ -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;
}
}
@@ -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);
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="org.hibernate.boot.model.source.internal.hbm">
<class name="HBMEntity" table="hbmentity" >
<id name="id" unsaved-value="0">
<generator class="sequence">
<param name="sequence">hbmentity_id_sequence</param>
</generator>
</id>
<many-to-one name="association" cascade="persist,save-update" not-null="true"/>
</class>

</hibernate-mapping>

0 comments on commit f1fa8bd

Please sign in to comment.