I am accesing to the database using a Dto with some entities and I want to improve the request without modifing my dto and removing the fetch so hibernate don´t return all the data from all the entities (hibernate is set to lazy), I tried with the next, but it´s not working:
StringBuilder hql = new StringBuilder();
hql.append(" select d.id as id, ce.cod as clasification.cod ");
hql.append(" from Document d");
hql.append(" join d.clasificacionEntity ce");
The working hql request:
StringBuilder hql = new StringBuilder();
hql.append(" select d");
hql.append(" from Document d");
hql.append(" join fetch d.clasificacionEntity ce");
The problem is when I try to use "ce.cod as clasification.cod" the second dot gives me a error, there is other way to do that? , thanks a lot!!!
My dto result is:
DocumentDto{
private id
private clasificacionEntityDto;
}
And
clasificacionEntityDto {
private cod
}