Query like this :
query1 = with codeList (bId, code) as ( select id, listagg(code, ',') ........)
select {A.*}, {B.*}, CL.code as codeListName from
tableA A left join tableB B on A.id = B.id
left join codeList CL on A.id = CL.bId
Result of the query would be like List of following values:
a.id, a.name, a.code, b.id, b.desc, b.addr , name
Can you let me know how to get the values using
query.addEntity("A", TableA.class).addJoin("B", "A.tableB").addScalar("codeListName", StryingType.Instance)
/// how to get the "codeListName" here? this addScalar is not working. Is this correct approach?
SQLQuery query = session.createSQLQuery(query1);
List<Object[]> rows = query .list();
As it's stated in the documentation:
For your case, the query will look like this:
Although it still returns an
Objectarrays, this query will not use theResultSetMetadataanymore since it explicitly gets the columns as respectively aBigIntegerand aStringfrom the underlyingResultSet. This also means that only these two columns will be returned, even though the query is still using * and theResultSetcontains more than the three listed columns.It is possible to leave out the type information for all or some of the scalars.