HHH-16711 / HHH-16707 - Added tests for these related issues
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
f2493040e3
commit
2076fc0976
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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.orm.test.inheritance.hhh16711;
|
||||
|
||||
import org.hibernate.orm.test.inheritance.hhh16711.otherPackage.Inherited;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "inheriting")
|
||||
class Inheriting extends Inherited {
|
||||
|
||||
Inheriting(String id, String name) {
|
||||
super(id, name);
|
||||
}
|
||||
|
||||
Inheriting() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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.orm.test.inheritance.hhh16711;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.orm.test.inheritance.hhh16711.otherPackage.Inherited;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@Jpa(
|
||||
annotatedClasses = {
|
||||
Inheriting.class,
|
||||
Inherited.class
|
||||
}
|
||||
)
|
||||
public class MappedSuperclassInheritanceTest {
|
||||
|
||||
@AfterEach
|
||||
public void cleanup(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> entityManager.createQuery( "delete from Inheriting" ).executeUpdate()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@JiraKey( value = "HHH-16707")
|
||||
public void testNew(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(entityManager -> {
|
||||
Inheriting inheriting = new Inheriting("myId", "myName");
|
||||
entityManager.persist( inheriting );
|
||||
});
|
||||
|
||||
scope.inTransaction(entityManager -> {
|
||||
List<Object[]> results = entityManager.createQuery( "SELECT i.id, i.name FROM Inheriting i", Object[].class).getResultList();
|
||||
assertEquals( 1, results.size() );
|
||||
assertEquals( "myId", results.get(0)[0].toString() );
|
||||
assertEquals( "myName", results.get(0)[1].toString() );
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@JiraKey( value = "HHH-16711")
|
||||
public void testSelect(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(entityManager -> {
|
||||
entityManager.createNativeQuery("INSERT INTO inheriting VALUES ('myId', 'myName')").executeUpdate();
|
||||
});
|
||||
|
||||
scope.inTransaction(entityManager -> {
|
||||
List<Inheriting> results = entityManager.createQuery( "SELECT i FROM Inheriting i", Inheriting.class).getResultList();
|
||||
assertEquals( 1, results.size() );
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.orm.test.inheritance.hhh16711.otherPackage;
|
||||
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class Inherited {
|
||||
@Id
|
||||
protected String id;
|
||||
protected String name;
|
||||
|
||||
protected Inherited(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
protected Inherited() {
|
||||
}
|
||||
|
||||
protected String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
protected String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
protected void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
protected void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue