|
19 | 19 | import static org.mockito.Mockito.*; |
20 | 20 |
|
21 | 21 | import jakarta.persistence.ElementCollection; |
| 22 | +import jakarta.persistence.Embeddable; |
| 23 | +import jakarta.persistence.Embedded; |
22 | 24 | import jakarta.persistence.EntityManager; |
23 | 25 | import jakarta.persistence.Id; |
24 | 26 | import jakarta.persistence.ManyToOne; |
|
67 | 69 | class JpaQueryCreatorTests { |
68 | 70 |
|
69 | 71 | private static final TestMetaModel ORDER = TestMetaModel.hibernateModel(Order.class, LineItem.class, Product.class); |
70 | | - private static final TestMetaModel PERSON = TestMetaModel.hibernateModel(Person.class); |
| 72 | + private static final TestMetaModel PERSON = TestMetaModel.hibernateModel(Person.class, EmailAddress.class); |
71 | 73 | private static final TestMetaModel REFERENCE_IDS = TestMetaModel.hibernateModel( |
72 | 74 | ReferencingEmbeddedIdExampleEmployee.class, EmbeddedIdExampleEmployee.class, EmbeddedIdExampleEmployeePK.class, |
73 | 75 | EmbeddedIdExampleDepartment.class); |
@@ -716,7 +718,8 @@ void tupleProjection(Class<?> resultType) { |
716 | 718 | .returning(resultType) // |
717 | 719 | .withParameters("chris") // |
718 | 720 | .as(QueryCreatorTester::create) // |
719 | | - .expectJpql("SELECT p.id id, p.firstname firstname, p.lastname lastname FROM %s p WHERE p.firstname = ?1", |
| 721 | + .expectJpql( |
| 722 | + "SELECT p.id id, p.emailAddress emailAddress, p.firstname firstname, p.lastname lastname FROM %s p WHERE p.firstname = ?1", |
720 | 723 | DefaultJpaEntityMetadata.unqualify(Person.class)) // |
721 | 724 | .validateQuery(); |
722 | 725 | } |
@@ -769,6 +772,18 @@ void createsJoinForReferenceName() { |
769 | 772 | .validateQuery(); |
770 | 773 | } |
771 | 774 |
|
| 775 | + @Test // GH-4087 |
| 776 | + void considersLeafPropertyTypeForIgnoreCase() { |
| 777 | + |
| 778 | + queryCreator(PERSON) // |
| 779 | + .forTree(Person.class, "findByEmailAddress_EmailIgnoreCase") // |
| 780 | + .withParameters("foo") // |
| 781 | + .as(QueryCreatorTester::create) // |
| 782 | + .expectJpql( |
| 783 | + "SELECT p FROM JpaQueryCreatorTests$Person p INNER JOIN p.emailAddress e WHERE UPPER(e.email) = UPPER(?1)") // |
| 784 | + .validateQuery(); |
| 785 | + } |
| 786 | + |
772 | 787 | QueryCreatorBuilder queryCreator(Metamodel metamodel) { |
773 | 788 | return new DefaultCreatorBuilder(metamodel); |
774 | 789 | } |
@@ -838,6 +853,13 @@ static class Person { |
838 | 853 | @Id Long id; |
839 | 854 | String firstname; |
840 | 855 | String lastname; |
| 856 | + |
| 857 | + @Embedded EmailAddress emailAddress; |
| 858 | + } |
| 859 | + |
| 860 | + @Embeddable |
| 861 | + static class EmailAddress { |
| 862 | + String email; |
841 | 863 | } |
842 | 864 |
|
843 | 865 | @jakarta.persistence.Entity |
|
0 commit comments