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