Hello,
Situation:
user(id,login)
user_address_relation(id,user_id,address_id)
address(id,naam,street..)
Question: why are the address entities proxied when using Projection.property? The relation is fully loaded in the primary query.
Query 1: List of proxied addresses is returned.
Code:
List<Address> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.setFetchMode("address",FetchMode.JOIN)
.setProjection(Projections.property("address")
.list();
Query 2: Addresses inside UserAddressRelation are fully loaded .
Code:
List<UserAddressRelation> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.setFetchMode("address",FetchMode.JOIN)
.list();
The same result for:
Query 1: List of proxied addresses is returned.
Code:
List<Address> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.createAlias("address","a",Criteria.INNER_JOIN)
.setProjection(Projections.property("address")
.list();
Query 2: Addresses inside UserAddressRelation are not proxied.
Code:
List<UserAddressRelation> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.createAlias("address","a",Criteria.INNER_JOIN)
.list();