diff --git a/orm/hibernate-orm-6/pom.xml b/orm/hibernate-orm-6/pom.xml index 39c973c1..5fdd00c3 100644 --- a/orm/hibernate-orm-6/pom.xml +++ b/orm/hibernate-orm-6/pom.xml @@ -11,7 +11,7 @@ 2.3.232 5.11.4 6.6.4.Final - 3.26.3 + 3.27.0 diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java index 3734df49..dd597fe9 100644 --- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java @@ -1,5 +1,9 @@ package org.hibernate.bugs; +import jakarta.persistence.Tuple; +import org.hibernate.Session; +import org.hibernate.bugs.model.Person; +import org.hibernate.query.criteria.HibernateCriteriaBuilder; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -8,6 +12,8 @@ import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.Persistence; +import java.util.List; + /** * This template demonstrates how to develop a test case for Hibernate ORM, using the Java Persistence API. */ @@ -32,6 +38,44 @@ void hhh123Test() throws Exception { EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); // Do stuff... + + final HibernateCriteriaBuilder cb = entityManager.unwrap(Session.class).getCriteriaBuilder(); + var wrapperQuery = cb.createTupleQuery(); + var subquery1 = wrapperQuery.subquery(Tuple.class); + var root1 = subquery1.from(Person.class); + subquery1.multiselect( + root1.get("id").alias("id"), + root1.get("firstName").alias("firstName"), + root1.get("lastName").alias("lastName"), + root1.get("email").alias("email"), + root1.get("phone").alias("phone"), + root1.get("address").alias("address")) + .where(cb.equal(root1.get("address").get("city"), "NYC")); + + var subquery2 = wrapperQuery.subquery(Tuple.class); + var root2 = subquery2.from(Person.class); + subquery2.multiselect( + root2.get("id").alias("id"), + root2.get("firstName").alias("firstName"), + root2.get("lastName").alias("lastName"), + root2.get("email").alias("email"), + root2.get("phone").alias("phone"), + root2.get("address").alias("address")) + .where(cb.like(root2.get("lastName"), "ba%")); + + var unionQuery = cb.union(subquery1, subquery2); + var wrapperRoot = wrapperQuery.from(unionQuery); + + wrapperQuery.multiselect( + wrapperRoot.get("id").alias("id"), + wrapperRoot.get("email").alias("email"), + wrapperRoot.get("address").alias("address") + ).orderBy(cb.desc(cb.literal(1))); + + List tuples = entityManager.createQuery(wrapperQuery).setMaxResults(5).getResultList(); + + System.out.println(tuples); + entityManager.getTransaction().commit(); entityManager.close(); } diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Address.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Address.java new file mode 100644 index 00000000..ade85b03 --- /dev/null +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Address.java @@ -0,0 +1,46 @@ +package org.hibernate.bugs.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class Address { + + @Column(name = "address_line1") + private String addressLine1; + + @Column(name = "city") + private String city; + + @Column(name = "state") + private String state; + + @Column(name = "zip") + private String zip; + + public Address() { + } + + public Address(String addressLine1, String city, String state, String zip) { + this.addressLine1 = addressLine1; + this.city = city; + this.state = state; + this.zip = zip; + } + + public String getAddressLine1() { + return addressLine1; + } + + public String getCity() { + return city; + } + + public String getState() { + return state; + } + + public String getZip() { + return zip; + } +} diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Person.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Person.java new file mode 100644 index 00000000..003f5d0f --- /dev/null +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Person.java @@ -0,0 +1,78 @@ +package org.hibernate.bugs.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "person") +public class Person { + @Id + @Column(name = "id") + private Long id; + + @Column(name = "first_name") + private String firstName; + + @Column(name = "last_name") + private String lastName; + + @Column(name = "email") + private String email; + + @Column(name = "phone") + private String phone; + + @Embedded + private Address address; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + address = address; + } +} \ No newline at end of file diff --git a/search/hibernate-search-5/elasticsearch-5/pom.xml b/search/hibernate-search-5/elasticsearch-5/pom.xml index e852266b..69c9c422 100644 --- a/search/hibernate-search-5/elasticsearch-5/pom.xml +++ b/search/hibernate-search-5/elasticsearch-5/pom.xml @@ -13,7 +13,7 @@ 2.3.232 5.11.4 - 3.26.3 + 3.27.0 UTF-8 UTF-8 diff --git a/search/hibernate-search-5/lucene/pom.xml b/search/hibernate-search-5/lucene/pom.xml index ea9822c8..ef9403a0 100644 --- a/search/hibernate-search-5/lucene/pom.xml +++ b/search/hibernate-search-5/lucene/pom.xml @@ -13,7 +13,7 @@ 2.3.232 5.11.4 - 3.26.3 + 3.27.0 UTF-8 UTF-8 diff --git a/search/hibernate-search-6/orm-elasticsearch/pom.xml b/search/hibernate-search-6/orm-elasticsearch/pom.xml index ef201b93..fbd76d4c 100644 --- a/search/hibernate-search-6/orm-elasticsearch/pom.xml +++ b/search/hibernate-search-6/orm-elasticsearch/pom.xml @@ -13,7 +13,7 @@ 2.3.232 5.11.4 - 3.26.3 + 3.27.0 UTF-8 UTF-8 diff --git a/search/hibernate-search-6/orm-lucene/pom.xml b/search/hibernate-search-6/orm-lucene/pom.xml index 2b1b81a0..a98f61ce 100644 --- a/search/hibernate-search-6/orm-lucene/pom.xml +++ b/search/hibernate-search-6/orm-lucene/pom.xml @@ -13,7 +13,7 @@ 2.3.232 5.11.4 - 3.26.3 + 3.27.0 UTF-8 UTF-8 diff --git a/search/hibernate-search-7/orm-elasticsearch/pom.xml b/search/hibernate-search-7/orm-elasticsearch/pom.xml index e41ee330..2af57c0d 100644 --- a/search/hibernate-search-7/orm-elasticsearch/pom.xml +++ b/search/hibernate-search-7/orm-elasticsearch/pom.xml @@ -15,7 +15,7 @@ 2.3.232 5.11.4 - 3.26.3 + 3.27.0 UTF-8 UTF-8 diff --git a/search/hibernate-search-7/orm-lucene/pom.xml b/search/hibernate-search-7/orm-lucene/pom.xml index e651026c..7fd86dde 100644 --- a/search/hibernate-search-7/orm-lucene/pom.xml +++ b/search/hibernate-search-7/orm-lucene/pom.xml @@ -15,7 +15,7 @@ 2.3.232 5.11.4 - 3.26.3 + 3.27.0 UTF-8 UTF-8 diff --git a/validator/validator-9/pom.xml b/validator/validator-9/pom.xml index 566d6c68..359acd7e 100644 --- a/validator/validator-9/pom.xml +++ b/validator/validator-9/pom.xml @@ -13,7 +13,7 @@ 9.0.0.CR1 6.0.0-M1 2.24.3 - 3.26.3 + 3.27.0 5.11.4