[hibernate-dev] SQM : Criteria translation design
Gunnar Morling
gunnar at hibernate.org
Mon Nov 2 08:06:28 EST 2015
Hi,
What exactly DYM by "The criteria nodes would be expected to implement
an SQM extension accepting a visitor"?
My first thought would have been a combination of the two approaches:
Let the criteria objects expose all the required data, make them
traversable by means of a visitor and have an SQM-specific visitor
implementation which converts each criteria object into its SQM
counter-part.
--Gunnar
2015-10-30 12:41 GMT+01:00 Steve Ebersole <steve at hibernate.org>:
> I started work on SQM-24 which covers translation of criteria queries into
> SQM.
>
> The difficulty with this is that the JPA contracts alone do not give enough
> information to really be able to understand the semantics of the query;
> there is just not enough information exposed. I can get into specific
> examples if that helps, but for now lets take that as a given...
>
> So then how do we go about translating a criteria into an SQM? There are
> going to be 2 main approaches. Each requires some level of extension to
> the standard contracts:
>
> The first approach is to use visitation. The criteria nodes would be
> expected to implement an SQM extension accepting a visitor and do the right
> thing. The gains here are the normal gains with the visitor pattern. The
> downside is that this makes SQM highly dependent on the criteria impl doing
> the right thing and makes the criteria impl sensitive to SQM (depending n
> how we expose the visitation methods to a degree).
>
> The second approach would be to extended the standard criteria contracts to
> more fully cover the semantic. As one example, JPA defines just Predicate
> (for the most part) without exposing the type of predicate. Is it a LIKE
> expression? A BETWEEN? A Comparison (=, !=, <, etc)? We just don't know
> from the standard contracts. So we'd have to develop a full semantic
> extension model here. `interface LikePredicate extends Predicate`,
> `BetweenPredicate extends Predicate`, etc.
>
> I lean towards the visitor approach given these choices. Anyone else have
> opinions? Other options?
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
More information about the hibernate-dev
mailing list