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
Sent: Wednesday, 28 June 2006 11:31 AM
To: hibernate-devel@lists.sourceforge.net
Subject: [Hibernate] (semi) Entity-type safe criteria queries

 

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.

This correspondence is for the named persons only.
It may contain confidential or privileged information or both.
No confidentiality or privilege is waived or lost by any mis transmission.
If you receive this correspondence in error please delete it from your system immediately and notify the sender.
You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient.
Any opinions expressed in this message are those of the individual sender except where the sender expressly,
and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.
This correspondence is for the named persons only.
It may contain confidential or privileged information or both.
No confidentiality or privilege is waived or lost by any mis transmission.
If you receive this correspondence in error please delete it from your system immediately and notify the sender.
You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient.
Any opinions expressed in this message are those of the individual sender except where the sender expressly,
and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.
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

Reply via email to