@@ -674,6 +674,121 @@ void orderByShouldWorkWithSubSelectStatements() {
674
674
+ "GROUP BY i2.field.id, i2.version)" , sort )).endsWith ("order by i.age desc" );
675
675
}
676
676
677
+ @ Test // GH-2864
678
+ void usingRightAsARelationshipNameShouldWork () {
679
+
680
+ JpqlQueryParser .parseQuery ("""
681
+ select u
682
+ from UserAccountEntity u
683
+ join u.lossInspectorLimitConfiguration lil
684
+ join u.companyTeam ct
685
+ where exists (
686
+ select iu
687
+ from UserAccountEntity iu
688
+ join iu.roles u2r
689
+ join u2r.role r
690
+ join r.rights r2r
691
+ join r2r.right rt
692
+ where
693
+ rt.code = :rightCode
694
+ and iu = u
695
+ )
696
+ and ct.id = :teamId
697
+ """ );
698
+ }
699
+
700
+ @ Test // GH-2864
701
+ void usingLeftAsARelationshipNameShouldWork () {
702
+
703
+ JpqlQueryParser .parseQuery ("""
704
+ select u
705
+ from UserAccountEntity u
706
+ join u.lossInspectorLimitConfiguration lil
707
+ join u.companyTeam ct
708
+ where exists (
709
+ select iu
710
+ from UserAccountEntity iu
711
+ join iu.roles u2r
712
+ join u2r.role r
713
+ join r.rights r2r
714
+ join r2r.left lt
715
+ where
716
+ lt.code = :rightCode
717
+ and iu = u
718
+ )
719
+ and ct.id = :teamId
720
+ """ );
721
+ }
722
+
723
+ @ Test // GH-2864
724
+ void usingOuterAsARelationshipNameShouldWork () {
725
+
726
+ JpqlQueryParser .parseQuery ("""
727
+ select u
728
+ from UserAccountEntity u
729
+ join u.lossInspectorLimitConfiguration lil
730
+ join u.companyTeam ct
731
+ where exists (
732
+ select iu
733
+ from UserAccountEntity iu
734
+ join iu.roles u2r
735
+ join u2r.role r
736
+ join r.rights r2r
737
+ join r2r.outer ou
738
+ where
739
+ ou.code = :rightCode
740
+ and iu = u
741
+ )
742
+ and ct.id = :teamId
743
+ """ );
744
+ }
745
+
746
+ @ Test // GH-2864
747
+ void usingFullAsARelationshipNameShouldWork () {
748
+
749
+ JpqlQueryParser .parseQuery ("""
750
+ select u
751
+ from UserAccountEntity u
752
+ join u.lossInspectorLimitConfiguration lil
753
+ join u.companyTeam ct
754
+ where exists (
755
+ select iu
756
+ from UserAccountEntity iu
757
+ join iu.roles u2r
758
+ join u2r.role r
759
+ join r.rights r2r
760
+ join r2r.full fu
761
+ where
762
+ fu.code = :rightCode
763
+ and iu = u
764
+ )
765
+ and ct.id = :teamId
766
+ """ );
767
+ }
768
+
769
+ @ Test // GH-2864
770
+ void usingInnerAsARelationshipNameShouldWork () {
771
+
772
+ JpqlQueryParser .parseQuery ("""
773
+ select u
774
+ from UserAccountEntity u
775
+ join u.lossInspectorLimitConfiguration lil
776
+ join u.companyTeam ct
777
+ where exists (
778
+ select iu
779
+ from UserAccountEntity iu
780
+ join iu.roles u2r
781
+ join u2r.role r
782
+ join r.rights r2r
783
+ join r2r.inner inr
784
+ where
785
+ inr.code = :rightCode
786
+ and iu = u
787
+ )
788
+ and ct.id = :teamId
789
+ """ );
790
+ }
791
+
677
792
private void assertCountQuery (String originalQuery , String countQuery ) {
678
793
assertThat (createCountQueryFor (originalQuery )).isEqualTo (countQuery );
679
794
}
0 commit comments