I am in the process of upgrading to Hibernate 5.3.4. This has caused some integration tests to fail. A couple of tables have columns names id
. This is causing the CONNECT BY clause required in this query block
error.
The methods in question are using Criteria queries. These queries are exploded into actual sql queries which have all the column names listed in the sql query as shown in the example below.
SELECT
this_.id AS id1_70_0_,
this_.ACCT_ID AS ACCT_ID2_70_0_,
this_.PROD_ID AS PROD_ID3_70_0_,
this_.in_type AS in_type4_70_0_,
this_.set_typ AS set_typ5_70_0_
FROM
SET_TYP this_
WHERE
this_.acct_id IN (
SELECT
acct_id
FROM
account
START WITH
acct_id = 630
CONNECT BY
PRIOR parent_acct_id = acct_id )
If I remove the Criteria query and use a sql query below instead it works fine.
SELECT
*
FROM
SET_TYP
WHERE
acct_id IN (
SELECT
a.acct_id
FROM
account a
START WITH
a.acct_id = 750
CONNECT BY
PRIOR parent_acct_id = a.acct_id )
How can I continue using criteria queries ?
Criteria query looks like this.
Criteria filter = getSession().createCriteria(SetTyp.class);
filter.add(Restrictions.sqlRestriction("acct_id in (select acct_id from account start with acct_id = ?0 connect by prior parent_acct_id = acct_id)", accountId, StandardBasicTypes.INTEGER));
Set<SettleTypeOverride> results = new TreeSet<>();
results.addAll(filter.list());