-
1. Re: accessing transient properties in EntityQuery Restrictions
gebuh Mar 9, 2012 8:29 PM (in response to cyberanto)1 of 1 people found this helpfulI don't see how you can do that using entityQuery restrictions at all. The restrictions are for querying the db table backing the entity. The transient field doesn't exist in that table. When you call getResultList() you're returning the entity, the transient field does exist in the entity.
-
2. Re: accessing transient properties in EntityQuery Restrictions
cyberanto Mar 13, 2012 11:44 AM (in response to cyberanto)After spending a little time looking into this, I realized that I was wrong about the EL not being resolved - it resolves just fine. So tranient properties *can* be used in the EL part of the Restrictions.
The problem is with demo.transientProperty (the left-hand-side of the comparison), which cannot be translated into SQL (thanks Beth). It could only be resolved *after* the SQL resultlist is returned and Entities are being created. While this would be nice from a simplicity/architectural point of view, it creates potentially very inefficient SQL queries and large result sets having to be retuned before the logic can be executed. So Hibernate avoids that, understandably so.
My goal was to avoid having BL in the query, and it all located in a non-anemic entity. Guess this is an OO/Relational Impedance issue that cannot be easily resolved.
Off to rewriting the query to include the necessary logic.