HHH-11554 - Added test case

This commit is contained in:
Andrea Boriero 2017-03-09 17:52:03 +00:00
parent 3398175ab3
commit fab264a8b2
6 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,13 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
/**
* @author Andrea Boriero
*/
public interface Common extends TestEntity {
}

View File

@ -0,0 +1,38 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.transaction.TransactionUtil;
import org.junit.Test;
/**
* @author Andrea Boriero
*/
public class JoinedSubclassWithRootInterfaceTest extends BaseCoreFunctionalTestCase {
@Override
protected String[] getMappings() {
return new String[] {"TestEntity.hbm.xml"};
}
@Override
protected String getBaseForMappings() {
return "org/hibernate/test/inheritance/discriminator/joinedsubclass/";
}
@Test
@TestForIssue( jiraKey = "HHH-11554")
public void testIt() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
final TestEntityImpl testEntity = new TestEntityImpl();
testEntity.setId( 1 );
session.save( testEntity );
} );
}
}

View File

@ -0,0 +1,14 @@
<!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.test.inheritance.discriminator.joinedsubclass">
<class name="TestEntityInterface" table="MY_ENTITY" abstract="true" discriminator-value="null">
<cache usage="transactional"/>
<id name="id" column="ID" access="property"/>
<discriminator column="TYPE" type="big_integer" force="true" />
</class>
<subclass name="TestEntityImpl" extends="TestEntityInterface" discriminator-value="1" lazy="false">
</subclass>
</hibernate-mapping>

View File

@ -0,0 +1,15 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
/**
* @author Andrea Boriero
*/
public interface TestEntity {
Integer getId();
void setId(Integer id);
}

View File

@ -0,0 +1,28 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
import javax.persistence.Id;
/**
* @author Andrea Boriero
*/
@javax.persistence.Entity
public class TestEntityImpl implements TestEntityInterface {
@Id
private Integer id;
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
}

View File

@ -0,0 +1,18 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
/**
* @author Andrea Boriero
*/
@javax.persistence.Entity
@Inheritance(strategy = InheritanceType.JOINED)
public interface TestEntityInterface extends Common {
}