Hi I am sending this again could anyone
tell me if this might be useful to the communitY? I would like to help if it would
be. Thanks, Dhanji, From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dhananjay Prasanna Hi All I am writing to ask about type-safety (in a very
rudimentary way) in Criteria queries. I know there has been some discussion
around this topic with the SODA group and others, but I am curious if this has
been considered for Hibernate. Basically, instead of using the system: Criteria q =
session.createCriteriaQuery(MyClass.class); q.add ( Restriction.eq(
“propName”, value) ); which is unsafe to the entity-type under query, would
it be possible to do something like: Criteria q = session.createSafeCriteriaQuery(MyClass.class); MyClass my =
q.obtainQueryable(MyClass.class); q.add( Restriction.eq(
my.getPropName(), value )); The special instance “my” would contain proxies or
bytecode-instrumented properties that would return the appropriate mapped
property name to the Criterion. Apart from being safe to the Entity type under
consideration (statically) and its properties, this approach has the added
advantage of bringing criteria queries into an IDE’s refactoring scope. The cons are the added performance hit of proxies or
bytecode manipulation, and the extra step in obtaining a reference to a
queryable entity. However I believe the pros far outweigh this, as my own
project occasionally undergoes property-refactoring and has a LOT of similarly-named
properties across classes (too many for a sane person to discriminate on
sight!). Anyway, I thought I would bring it up—Im sure
typesafety has been discussed before so please forgive me if this is a rehash.
I’m also happy to contribute an implementation of this if you guys find
it worth adding. Thanks!! Dhanji.
|
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel