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.TableGenerator;
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.SessionFactoryScope;
import org.junit.jupiter.api.Test;
@ -16,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel(annotatedClasses =
{ClassLevelGeneratorTest.EntityWithAnonSequenceGenerator.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 {
@Test
void testAnonGenerator(SessionFactoryScope scope) {

View File

@ -6,6 +6,8 @@ import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TableGenerator;
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.SessionFactoryScope;
import org.junit.jupiter.api.Test;
@ -16,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel(annotatedClasses =
{FieldLevelGeneratorTest.EntityWithAnonSequenceGenerator.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 {
@Test
void testAnonGenerator(SessionFactoryScope scope) {

View File

@ -4,6 +4,8 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
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.SessionFactoryScope;
import org.junit.jupiter.api.Test;
@ -14,6 +16,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel(annotatedClasses =
{PackageLevelGeneratorTest.EntityWithAnonSequenceGenerator.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 {
@Test
void testAnonGenerator(SessionFactoryScope scope) {

View File

@ -9,20 +9,24 @@ import jakarta.persistence.Id;
import jakarta.persistence.NamedNativeQuery;
import jakarta.persistence.Table;
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.SessionFactoryScope;
import org.junit.jupiter.api.Test;
@SessionFactory
@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 {
@Test void test(SessionFactoryScope scope) {
Mapped mapped = new Mapped();
mapped.name = "Gavin";
scope.inTransaction(s -> s.persist(mapped));
scope.inSession(s -> {
s.createNamedSelectionQuery("mapped-native-query").getSingleResult();
s.createNamedSelectionQuery("unmapped-native-query").getSingleResult();
s.createNamedSelectionQuery("mapped-native-query",Object[].class).getSingleResult();
s.createNamedSelectionQuery("unmapped-native-query",Object[].class).getSingleResult();
});
}
@NamedNativeQuery(

View File

@ -5,12 +5,16 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
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.SessionFactoryScope;
import org.junit.jupiter.api.Test;
@SessionFactory
@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 {
@Test
void test(SessionFactoryScope scope) {
@ -23,14 +27,18 @@ public class HQLThisTest {
s.createSelectionQuery("select id(this) from This").getSingleResult();
});
}
@Entity
@Entity(name="This")
static class This {
@Id @GeneratedValue
long id;
@Basic(optional = false)
String name;
This(String gavin) {}
This() {}
This(String name) {
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.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.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
@ -121,6 +123,8 @@ public class EntityResultTests extends AbstractUsageTest {
}
@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) {
scope.inTransaction(
session -> {