HHH-18498 - Generator on package level does not work when the name is not specified

HHH-18499 - Some new functions in Persistence 3.2 does not work
HHH-18536 - Support implicit "this" alias in HQL
HHH-18537 - Support Session#createNamedSelectionQuery for native-query
This commit is contained in:
Steve Ebersole 2024-08-28 17:10:48 -05:00
parent a82ac08d14
commit 08bd466703
6 changed files with 33 additions and 5 deletions

View File

@ -6,6 +6,8 @@ import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator; import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TableGenerator; import jakarta.persistence.TableGenerator;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -16,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel(annotatedClasses = @DomainModel(annotatedClasses =
{ClassLevelGeneratorTest.EntityWithAnonSequenceGenerator.class, {ClassLevelGeneratorTest.EntityWithAnonSequenceGenerator.class,
ClassLevelGeneratorTest.EntityWithAnonTableGenerator.class}) ClassLevelGeneratorTest.EntityWithAnonTableGenerator.class})
@FailureExpected( reason = "Support for unnamed generators is not implemented yet" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-18498" )
public class ClassLevelGeneratorTest { public class ClassLevelGeneratorTest {
@Test @Test
void testAnonGenerator(SessionFactoryScope scope) { void testAnonGenerator(SessionFactoryScope scope) {

View File

@ -6,6 +6,8 @@ import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator; import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TableGenerator; import jakarta.persistence.TableGenerator;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -16,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel(annotatedClasses = @DomainModel(annotatedClasses =
{FieldLevelGeneratorTest.EntityWithAnonSequenceGenerator.class, {FieldLevelGeneratorTest.EntityWithAnonSequenceGenerator.class,
FieldLevelGeneratorTest.EntityWithAnonTableGenerator.class}) FieldLevelGeneratorTest.EntityWithAnonTableGenerator.class})
@FailureExpected( reason = "Support for unnamed generators is not implemented yet" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-18498" )
public class FieldLevelGeneratorTest { public class FieldLevelGeneratorTest {
@Test @Test
void testAnonGenerator(SessionFactoryScope scope) { void testAnonGenerator(SessionFactoryScope scope) {

View File

@ -4,6 +4,8 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,6 +16,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel(annotatedClasses = @DomainModel(annotatedClasses =
{PackageLevelGeneratorTest.EntityWithAnonSequenceGenerator.class, {PackageLevelGeneratorTest.EntityWithAnonSequenceGenerator.class,
PackageLevelGeneratorTest.EntityWithAnonTableGenerator.class}) PackageLevelGeneratorTest.EntityWithAnonTableGenerator.class})
@FailureExpected( reason = "Support for unnamed generators is not implemented yet" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-18498" )
public class PackageLevelGeneratorTest { public class PackageLevelGeneratorTest {
@Test @Test
void testAnonGenerator(SessionFactoryScope scope) { void testAnonGenerator(SessionFactoryScope scope) {

View File

@ -9,20 +9,24 @@ import jakarta.persistence.Id;
import jakarta.persistence.NamedNativeQuery; import jakarta.persistence.NamedNativeQuery;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@SessionFactory @SessionFactory
@DomainModel(annotatedClasses = NamedNativeQueryWithResultMappingTest.Mapped.class) @DomainModel(annotatedClasses = NamedNativeQueryWithResultMappingTest.Mapped.class)
@FailureExpected( jiraKey = "HHH-18537", reason = "Call to #createNamedSelectionQuery for native-query, which never worked." )
@Jira( "https://hibernate.atlassian.net/browse/HHH-18537" )
public class NamedNativeQueryWithResultMappingTest { public class NamedNativeQueryWithResultMappingTest {
@Test void test(SessionFactoryScope scope) { @Test void test(SessionFactoryScope scope) {
Mapped mapped = new Mapped(); Mapped mapped = new Mapped();
mapped.name = "Gavin"; mapped.name = "Gavin";
scope.inTransaction(s -> s.persist(mapped)); scope.inTransaction(s -> s.persist(mapped));
scope.inSession(s -> { scope.inSession(s -> {
s.createNamedSelectionQuery("mapped-native-query").getSingleResult(); s.createNamedSelectionQuery("mapped-native-query",Object[].class).getSingleResult();
s.createNamedSelectionQuery("unmapped-native-query").getSingleResult(); s.createNamedSelectionQuery("unmapped-native-query",Object[].class).getSingleResult();
}); });
} }
@NamedNativeQuery( @NamedNativeQuery(

View File

@ -5,12 +5,16 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@SessionFactory @SessionFactory
@DomainModel(annotatedClasses = HQLThisTest.This.class) @DomainModel(annotatedClasses = HQLThisTest.This.class)
@FailureExpected( jiraKey = "HHH-18536", reason = "Support implicit \"this\" alias in HQL" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-18536" )
public class HQLThisTest { public class HQLThisTest {
@Test @Test
void test(SessionFactoryScope scope) { void test(SessionFactoryScope scope) {
@ -23,14 +27,18 @@ public class HQLThisTest {
s.createSelectionQuery("select id(this) from This").getSingleResult(); s.createSelectionQuery("select id(this) from This").getSingleResult();
}); });
} }
@Entity @Entity(name="This")
static class This { static class This {
@Id @GeneratedValue @Id @GeneratedValue
long id; long id;
@Basic(optional = false) @Basic(optional = false)
String name; String name;
This(String gavin) {} This(String name) {
This() {} this.name = name;
}
This() {
}
} }
} }

View File

@ -23,6 +23,8 @@ import org.hibernate.query.named.NamedResultSetMappingMemento;
import org.hibernate.testing.orm.domain.gambit.EntityOfBasics; import org.hibernate.testing.orm.domain.gambit.EntityOfBasics;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
@ -121,6 +123,8 @@ public class EntityResultTests extends AbstractUsageTest {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-18535", reason = "Support for @EntityResult(lockMode) not implemented yet")
@Jira( "https://hibernate.atlassian.net/browse/HHH-18535" )
public void testImplicitAttributeMappingWithLockMode(SessionFactoryScope scope) { public void testImplicitAttributeMappingWithLockMode(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {