HHH-15369 Add test for issue

This commit is contained in:
Andrea Boriero 2022-06-28 12:38:54 +02:00 committed by Andrea Boriero
parent fcabfa400a
commit 9f288c3520
8 changed files with 184 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package org.hibernate.orm.test.hbm.inheritance;
public abstract class Animal {
private long id;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.orm.test.hbm.inheritance">
<class name="AnimalReport">
<id name="id"/>
<property name="name"/>
<many-to-one class="Animal" name="animal" not-found="ignore"/>
</class>
<class abstract="true" name="Animal">
<id name="id"/>
<joined-subclass name="Cat">
<key column="ANIMAL_ID"/>
<many-to-one class="CatName" name="name" not-found="ignore"/>
</joined-subclass>
<joined-subclass name="Dog">
<key column="ANIMAL_ID"/>
<many-to-one class="DogName" name="name" not-found="ignore"/>
</joined-subclass>
</class>
<class name="CatName">
<id name="id"/>
<property name="name"/>
</class>
<class name="DogName">
<id name="id"/>
<property name="name"/>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,34 @@
package org.hibernate.orm.test.hbm.inheritance;
public class AnimalReport {
private long id;
private String name;
private Animal animal;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Animal getAnimal() {
return animal;
}
public void setAnimal(Animal animal) {
this.animal = animal;
}
}

View File

@ -0,0 +1,14 @@
package org.hibernate.orm.test.hbm.inheritance;
public class Cat extends Animal {
private CatName name;
public CatName getName() {
return name;
}
public void setName(CatName name) {
this.name = name;
}
}

View File

@ -0,0 +1,24 @@
package org.hibernate.orm.test.hbm.inheritance;
public class CatName {
private long id;
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,14 @@
package org.hibernate.orm.test.hbm.inheritance;
public class Dog extends Animal {
private DogName name;
public DogName getName() {
return name;
}
public void setName(DogName name) {
this.name = name;
}
}

View File

@ -0,0 +1,24 @@
package org.hibernate.orm.test.hbm.inheritance;
public class DogName {
private long id;
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,23 @@
package org.hibernate.orm.test.hbm.inheritance;
import org.hibernate.boot.MetadataSources;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
import org.junit.jupiter.api.Test;
@ServiceRegistry
public class JoinedSubclassesWithSameFieldNamesButDifferentTypesTest {
@Test
@TestForIssue(jiraKey = "HHH-15369")
public void testNoExceptionIsThrown(ServiceRegistryScope scope) {
try (final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources( scope.getRegistry() )
.addResource( "org/hibernate/orm/test/hbm/inheritance/AnimalReport.hbm.xml" )
.buildMetadata()
.buildSessionFactory()) {
}
}
}