Skip to content

Commit fab264a

Browse files
committed
HHH-11554 - Added test case
1 parent 3398175 commit fab264a

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
8+
9+
/**
10+
* @author Andrea Boriero
11+
*/
12+
public interface Common extends TestEntity {
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
8+
9+
import org.hibernate.testing.TestForIssue;
10+
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
11+
import org.hibernate.testing.transaction.TransactionUtil;
12+
import org.junit.Test;
13+
14+
/**
15+
* @author Andrea Boriero
16+
*/
17+
public class JoinedSubclassWithRootInterfaceTest extends BaseCoreFunctionalTestCase {
18+
19+
@Override
20+
protected String[] getMappings() {
21+
return new String[] {"TestEntity.hbm.xml"};
22+
}
23+
24+
@Override
25+
protected String getBaseForMappings() {
26+
return "org/hibernate/test/inheritance/discriminator/joinedsubclass/";
27+
}
28+
29+
@Test
30+
@TestForIssue( jiraKey = "HHH-11554")
31+
public void testIt() {
32+
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
33+
final TestEntityImpl testEntity = new TestEntityImpl();
34+
testEntity.setId( 1 );
35+
session.save( testEntity );
36+
} );
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE hibernate-mapping PUBLIC
2+
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
3+
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
4+
<hibernate-mapping package="org.hibernate.test.inheritance.discriminator.joinedsubclass">
5+
<class name="TestEntityInterface" table="MY_ENTITY" abstract="true" discriminator-value="null">
6+
<cache usage="transactional"/>
7+
<id name="id" column="ID" access="property"/>
8+
<discriminator column="TYPE" type="big_integer" force="true" />
9+
</class>
10+
11+
<subclass name="TestEntityImpl" extends="TestEntityInterface" discriminator-value="1" lazy="false">
12+
13+
</subclass>
14+
</hibernate-mapping>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
8+
9+
/**
10+
* @author Andrea Boriero
11+
*/
12+
public interface TestEntity {
13+
Integer getId();
14+
void setId(Integer id);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
8+
9+
import javax.persistence.Id;
10+
11+
/**
12+
* @author Andrea Boriero
13+
*/
14+
@javax.persistence.Entity
15+
public class TestEntityImpl implements TestEntityInterface {
16+
@Id
17+
private Integer id;
18+
19+
@Override
20+
public Integer getId() {
21+
return id;
22+
}
23+
24+
@Override
25+
public void setId(Integer id) {
26+
this.id = id;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.inheritance.discriminator.joinedsubclass;
8+
9+
import javax.persistence.Inheritance;
10+
import javax.persistence.InheritanceType;
11+
12+
/**
13+
* @author Andrea Boriero
14+
*/
15+
@javax.persistence.Entity
16+
@Inheritance(strategy = InheritanceType.JOINED)
17+
public interface TestEntityInterface extends Common {
18+
}

0 commit comments

Comments
 (0)