我想使用springboot jpa实现下面的查询,有可能吗?
select * from
Claims.misuser.CLXMstApplicationRole AR WITH (NOLOCK) INNER JOIN
PADB.misuser.clxmstaccesspermission AP WITH (NOLOCK) ON
AP.intApplicationRoleId = AR.intApplicationRoleId
where AR.txtApplicationRoleCode = 'CRUAPP'
我已经在存储库界面中编写了以下代码
@Query(value=QueryConstants.InnerJoin_AppRole_AccessPermission)
List<ApplicationRole> findBy_InnerJoin_AppRole_AccessPermission();
QueryConstants.java
InnerJoin_AppRole_AccessPermission="select AR FROM com.infosys.claims.broadband.springboot.entity.claims.ApplicationRole AR "+
"INNER JOIN com.infosys.claims.broadband.springboot.entity.padb.AccessPermission AP"+
"ON AR.applicationRole = AP.applicationRoleId" +
"where AR.applicationRoleCode = 'CRUAPP' ";
但这给了我一个空列表,在mssql中,它给了我记录。
答案 0 :(得分:0)
您可以按原样使用查询。
@Query(value = "select * from
Claims.misuser.CLXMstApplicationRole AR WITH (NOLOCK) INNER JOIN
PADB.misuser.clxmstaccesspermission AP WITH (NOLOCK) ON
AP.intApplicationRoleId = AR.intApplicationRoleId
where AR.txtApplicationRoleCode = (?1)", nativeQuery = true)
List<ApplicationRole> findBy_InnerJoin_AppRole_AccessPermission(ApplicationRoleCode crudApp);
只需将变量crudApp
的值设置为"CRUAPP"
。
,nativeQuery = true)
非常容易!