Hibernate version: 3.1.2 w/ Annotations
Name and version of the database you are using: MySQL 4.1
I am looking for a way to reliably guess type information for named parameters in HQL queries. My queries are generally in @NamedQuery annotations if it matters.
I did a little digging in the source code and some pieces look promising (Namely the HQLQueryPlan.getParameterMetaData()). It looks like most of this API is under the hood, exposed via SessionFactoryImplementor but not via the SessionFactory interface I'm accustomed to using.
Is there a "public api" sort of way to get at this information? Would it be reasonable to cast my SessionFactory to a SessionFactoryImpl so I can access the query plan cache?
Specifically, suppose I have a named HQL query:
Code:
from Product where partNumber = :partNumber
At runtime, I'd like to determine the best java type for the "partNumber" parameter in my query. My ultimate goal is to generate typesafe wrappers for my queries at build time using a custom ant task.
I suspect there are cases where the type can't be reliably determined. If there are any considerations along these lines I'd love to hear them as well.
I know this is an abnormal use of Hibernate, but if anyone has any guidance before I start writing code it would certainly save me a lot of wrong directions before I figure it out. Thanks so much!
Geoff