openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <>
Subject Re: Slice QueryTargetPolicy with Criteria API
Date Tue, 10 May 2011 16:52:20 GMT
> I was wondering what happens with the QueryTargetPolicy when you execute
Criteria API based queries. 

I think it will bomb :)
Slice was developed before Criteria Query came into being.

Background info:
The internal structure that carries the to name of the target slices to
query execution module is FetchConfiguration. And the target slice names are
attached to FetchConfiguration as hint with key "openjpa.hint.slice.Target"
or typo-safe logical constant SlicePersistence.HINT_TARGET. 

Now normal, spec-compliant method Query.setHint(...) also populate the same

Given this background, an user application using Slice can always call
javax.persistence.Query q = // create query by JPQL or Criteria
List<String> myListOfTargetSliceNames = // decision logic to target a query
to subset of slices
q.setHint(SlicePersistence.HINT_TARGET, myListOfTargetSliceNames);

The introduction of QueryTargetPolicy is actually a thin wrapper so that 
a) user application can localize the the logic that determines the target
slice names for each query. 
b) the requisite  q.setHint(..) gets automagically called by Slice runtime
before query execution, so user application does not have to.  

So effectively,
  a) Queries can be targeted for Criteria Query as well with currently
available mechanics
  b) A user application can as well build a discipline (that does *not*
implement QueryTargetPolicy)  by directly setting hints on spec-compliant
Query interface before execution. 

  Thank you for using Slice :)

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message