Michael, Your situation sounds similar to one I solved with a database view. Is it possible in your environment to introduce a new view and build a new JPA entity on top of that? If so, add the view and define it with whatever derived columns you need to support your use cases using only standard EJB-QL.
This approach will leave you with the problem of updating. In my admittedly simple application, the view was used only for search. When I needed to get more detail or perform an update, I'd fetch the "real" entity by it's key (which I included in the view). I understand it's also possible to create updatable views (I was using DB2), but I didn't try that. --Rich -----Original Message----- From: Michael Vorburger [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 06, 2008 10:18 AM To: [email protected] Subject: RE: Queries using specific SQL, e.g. functions, or specific operators - passthrough SQL pieces without full native query By chance I just "stumbled upon" the JDBCFilterListener interface, while looking for something totally different. It's implementations like GetColumn and more interestingly SQLEmbed, that "price < sql(\"(SELECT AVG (PRICE) FROM PRODUCT_TABLE)\")", look pretty interesting, and I think is for what I was asking for below? BUT these have @nojavadoc in the .java, there is nothing about this in the Doc, and I couldn't find anything by Googling... (unless I'm blind), so may be this is not the way to do this?? Would love some feedback on this from experts! -----Original Message----- From: Michael Vorburger [mailto:[EMAIL PROTECTED] Sent: lundi, 4. août 2008 18:47 To: [email protected] Subject: Queries using specific SQL, e.g. functions, or specific operators - passthrough SQL pieces without full native query Hello, We would like to create a JPA query where one piece of the WHERE is totally customized - a sort of "pass through" for a condition, imagine to e.g. call an SQL function from a DB that JPQL doesn't cover (something beyond e.g. CURRENT_DATE or the standard String functions; the exact use case is something to do with date comparison stuff, compare some datetime column without taking the year into account, something fun; but I'm trying to formulate it a bit more abstract.) I'm sure there is some way to do this? Full SQL native query passthrough is not really the answer here - as we do want JPQL (traversing relations) for other parts of the query, just on one field some SQL function should be executed. Thanks a lot, Michael _____________________________ Michael Vorburger, Odyssey Financial Technologies ____________________________________________________________ * This email and any files transmitted with it are CONFIDENTIAL and intended solely for the use of the individual or entity to which they are addressed. * Any unauthorized copying, disclosure, or distribution of the material within this email is strictly forbidden. * Any views or opinions presented within this e-mail are solely those of the author and do not necessarily represent those of Odyssey Financial Technologies SA unless otherwise specifically stated. * An electronic message is not binding on its sender. Any message referring to a binding engagement must be confirmed in writing and duly signed. * If you have received this email in error, please notify the sender immediately and delete the original.
