2

I am currently doing the following:

 Query q = session.createQuery("select x,s.id from com.package.IdLookupHDO x JOIN com.package.SourceDataHDO s ON x.identifier = s.sourcePrimaryIdentifier");
        for (Object obj : q.list()){

        }

I think this join query will work without a problem. However I expected the query to give back object arrays in the list method because I have requested two things in my select (IdLookupHDO and id). I have searched around and cannot find an answer but how can I retrieve both selected objects?

0

1 Answer 1

3

You don't need on if you have a corresponding association in your persistent classes.

Query q = session.createQuery("select x,s.id from IdLookupHDO x join x.sourceAssociation s");

This query will return the List<Object[]>

List<Object[]> result = (List<Object[]>)q.list();

for (Object[] obj : result){
  // obj[0] is x
  // obj[1] is s.id
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.