下面是我想要转换为HQL的sql。有人可以帮我这个吗?我也发布了我的HQL,目前正在给我一个nullpointer异常 -
select ti.tax_id_no,
u1.user_id,
u1.user_nm_fst,
u1.user_nm_lst,
u1.user_ph_no,
u1.user_email
from pcmp.tax_identifier ti
inner join (select ucax.user_id, ucax.cust_id
from pcmp.users_customer_access_xref ucax
where ucax.ptcp_typ_cd = 'insrd'
and ucax.void_ind = 'n'
and ucax.user_cust_accs_xref_end_dt is null) ucax1
on ucax1.cust_id = ti.cust_id
inner join (select u.user_id,
u.user_nm_fst,
u.user_nm_lst,
u.user_ph_no,
u.user_email
from pcmp.users u
where u.user_end_dt is null
and u.user_void_ind = 'n') u1
on u1.user_id = ucax1.user_id
where ti.tax_id_no = '830204947'-- '465202523'
and ti.void_ind = 'n'
and ti.tax_id_end_dt is null
我尝试使用以下查询但遇到了错误 -
String queryString = "select u from User u"
+ " INNER JOIN u.ucax userCustomerAccessXref"
+ " INNER JOIN u.ti taxIdentifier"
+ " where taxIdentifier.tax_id_id = ?1";
我使用上述查询的例外是 -
显示java.lang.NullPointerException
org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:383)
org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3585)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3366)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3239)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:726)
答案 0 :(得分:0)
告诉我们您正在运行哪个版本的hibernate。 可能有助于说明您的问题尽可能可重复用于其他人。 对于那些不在你的业务领域的人来说,你的内心联系似乎非常复杂......
每当你通过连接字符串来启动查询时...对我而言,这表明你失去了对业务领域的控制权,因为你没有选择指定外部化的jpa / hibernate查询的方式。