HHH-15744 Add test for issue
This commit is contained in:
parent
0d20cea0b3
commit
5a89c34127
|
@ -0,0 +1,74 @@
|
|||
package org.hibernate.orm.test.polymorphic;
|
||||
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@DomainModel(
|
||||
annotatedClasses = PolymorphicQueriesTest2.Human.class
|
||||
)
|
||||
@SessionFactory
|
||||
@TestForIssue( jiraKey = "HHH-15744")
|
||||
public class PolymorphicQueriesTest2 {
|
||||
|
||||
|
||||
@BeforeAll
|
||||
public void setUp(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.persist( new Human( "Fab" ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
QueryImplementor<Animal> query = session.createQuery(
|
||||
"from org.hibernate.orm.test.polymorphic.PolymorphicQueriesTest2$Animal u where (u.name = ?1)",
|
||||
Animal.class
|
||||
);
|
||||
query.setParameter( 1, "Fab" );
|
||||
query.list();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public interface Animal {
|
||||
String getName();
|
||||
}
|
||||
|
||||
@Entity(name = "Human")
|
||||
public static class Human implements Animal {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Human() {
|
||||
}
|
||||
|
||||
public Human(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue