user810430
user810430

Reputation: 11499

How in hql query select part of object?

I need tune query for performance. The tree of objects like:

classA {
 classB b;
 classC c;
.....}

I need select similar to SQL:

select a.field1, b.field2, c.field3, c.field4 from a left outer join b 
  on a.id=b.fk left outer join c on b.id=c.fk

I don't understand what kind of result will be returned, does it arrayList? Or query returns all 3 objects? Thanks.

Upvotes: 0

Views: 466

Answers (3)

Pramod Kumar
Pramod Kumar

Reputation: 8014

The result which would be returned by the query would be type of -

 List<Object[]>

Upvotes: 2

alexey28
alexey28

Reputation: 5230

If you use HQL I think you use hibernate. Provide mapping with relations (ManyToOne or OneToOne) to your objects:

class A {

    @ManyToOne
    pribvate B b;

    @OneToOne
    private C c;
}

Then use session methods to select your object A with hql query of criteria. Hibernate do all joins for you automatically. And it will return List of A.

Upvotes: 1

manurajhada
manurajhada

Reputation: 5390

It will be

List<Object[]> list = new ArrayList<Object[]>();

Upvotes: 2

Related Questions