@@ -793,6 +793,121 @@ void sortProperlyAppendsToExistingOrderByWithFunction() {
793
793
"select e from SampleEntity e where function('nativeFunc', ?1) > 'testVal' order by function('nativeFunc', ?1), e.age desc" );
794
794
}
795
795
796
+ @ Test // GH-2864
797
+ void usingRightAsARelationshipNameShouldWork () {
798
+
799
+ HqlQueryParser .parseQuery ("""
800
+ select u
801
+ from UserAccountEntity u
802
+ join fetch u.lossInspectorLimitConfiguration lil
803
+ join fetch u.companyTeam ct
804
+ where exists (
805
+ select iu
806
+ from UserAccountEntity iu
807
+ join iu.roles u2r
808
+ join u2r.role r
809
+ join r.rights r2r
810
+ join r2r.right rt
811
+ where
812
+ rt.code = :rightCode
813
+ and iu = u
814
+ )
815
+ and ct.id = :teamId
816
+ """ );
817
+ }
818
+
819
+ @ Test // GH-2864
820
+ void usingLeftAsARelationshipNameShouldWork () {
821
+
822
+ HqlQueryParser .parseQuery ("""
823
+ select u
824
+ from UserAccountEntity u
825
+ join fetch u.lossInspectorLimitConfiguration lil
826
+ join fetch u.companyTeam ct
827
+ where exists (
828
+ select iu
829
+ from UserAccountEntity iu
830
+ join iu.roles u2r
831
+ join u2r.role r
832
+ join r.rights r2r
833
+ join r2r.left lt
834
+ where
835
+ lt.code = :rightCode
836
+ and iu = u
837
+ )
838
+ and ct.id = :teamId
839
+ """ );
840
+ }
841
+
842
+ @ Test // GH-2864
843
+ void usingOuterAsARelationshipNameShouldWork () {
844
+
845
+ HqlQueryParser .parseQuery ("""
846
+ select u
847
+ from UserAccountEntity u
848
+ join fetch u.lossInspectorLimitConfiguration lil
849
+ join fetch u.companyTeam ct
850
+ where exists (
851
+ select iu
852
+ from UserAccountEntity iu
853
+ join iu.roles u2r
854
+ join u2r.role r
855
+ join r.rights r2r
856
+ join r2r.outer ou
857
+ where
858
+ ou.code = :rightCode
859
+ and iu = u
860
+ )
861
+ and ct.id = :teamId
862
+ """ );
863
+ }
864
+
865
+ @ Test // GH-2864
866
+ void usingFullAsARelationshipNameShouldWork () {
867
+
868
+ HqlQueryParser .parseQuery ("""
869
+ select u
870
+ from UserAccountEntity u
871
+ join fetch u.lossInspectorLimitConfiguration lil
872
+ join fetch u.companyTeam ct
873
+ where exists (
874
+ select iu
875
+ from UserAccountEntity iu
876
+ join iu.roles u2r
877
+ join u2r.role r
878
+ join r.rights r2r
879
+ join r2r.full fu
880
+ where
881
+ fu.code = :rightCode
882
+ and iu = u
883
+ )
884
+ and ct.id = :teamId
885
+ """ );
886
+ }
887
+
888
+ @ Test // GH-2864
889
+ void usingInnerAsARelationshipNameShouldWork () {
890
+
891
+ HqlQueryParser .parseQuery ("""
892
+ select u
893
+ from UserAccountEntity u
894
+ join fetch u.lossInspectorLimitConfiguration lil
895
+ join fetch u.companyTeam ct
896
+ where exists (
897
+ select iu
898
+ from UserAccountEntity iu
899
+ join iu.roles u2r
900
+ join u2r.role r
901
+ join r.rights r2r
902
+ join r2r.inner in
903
+ where
904
+ in.code = :rightCode
905
+ and iu = u
906
+ )
907
+ and ct.id = :teamId
908
+ """ );
909
+ }
910
+
796
911
private void assertCountQuery (String originalQuery , String countQuery ) {
797
912
assertThat (createCountQueryFor (originalQuery )).isEqualTo (countQuery );
798
913
}
0 commit comments