0

Below is my sql which i want to convert to HQL. Can someone please help me with this ? I am also posting my HQL which is currently giving me a nullpointer exception -

   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

I tried using the below query but ran into errors -

        String queryString = "select u from User u"
                + " INNER JOIN u.ucax userCustomerAccessXref"                   
                + " INNER JOIN u.ti taxIdentifier"
                + " where taxIdentifier.tax_id_id = ?1"; 

The exception I get using the above query is -

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)

1 Answers1

1

let us know which version of hibernate you are running. probably it would help to state your problem as reproducable as possible for others. your inner join seem to be very complicated to anyone who is not in your business domain...

whenever you start queries by concatenating strings ... for me it is an indication you lost control on your business domain since you do not choose the way of specifiying jpa/hibernate queries externalized.

Dirk Schumacher
  • 1,479
  • 19
  • 37