[hibernate-dev] RFC: implement criteria API query of collection-of-component and collection-of-value
hibernate at dm.cobite.com
Sun Dec 14 18:09:40 EST 2008
The attached patch, which is NOT ready for inclusion, but works
completely under very light testing, implements the functionality
missing from the criteria API for querying collections that are not
collection-of-entity. (ie. fix the causes of 'collection is not an
association', (i.e first issue on 'Advanced Problems' faq)).
This needs some feedback and review. I have created issue
track the issue, but I've not yet received any feedback.
The main area of change is to the CriteriaQueryTranslator class. In
this class, we replace the 'criteriaEntityNames' map of Criteria =>
String with two maps, one mapping Criteria => CriteriaInfoProvider and
one mapping String (name) => CriteriaInfoProvider.
The new class, CriteriaInfoProvider is an interface/abstraction to the
functionality needed by the various entry points into the translator,
such as to retrieve the 'spaces', get the PropertyMapping etc.
There are 3 concrete implementations of CriteriaInfoProvider:
* EntityCriteriaInfoProvider: this is the functionality that was always
present in the translator, ie. use getEntityPersister() etc.
* ComponentCollectionInfoProvider: this is the functionality that
extends the api for collection-of-component. In this class, we have to
provide the collection 'spaces' and the 'collection persister', but we
also have to look in detail at the ComponentType to be able to resolve
property references off of the component.
* ScalarCollectionInfoProvider: this is the functionality the provides
the api for collection-of-value. The main thing here is we use the
SessionFactoryHelper (part of the HQL tree) to get the
CollectionPropertyMapping object for mapping the 'elements','indices'
etc. properties. There's at least one 'I have no idea what to put here'
method in this class.
There is substantial cruft in the patch for debugging, which will not be
part of the final implementation.
There is a crude hack in CriteriaJoinWalker which needs some expert
advice: the existing implementation was looking at some mysterious
'consumesEntityAlias' boolean, but I need to force the code to lookup
the alias from the translator every time, or else it bypasses the alias
for the collection itself, and the SQL aliases are wrong.
There is also a completely separate bugfix wedged in here, which needs
to be extracted to its own issue/patch. The changes to JoinWalker are
necessary and correct: if the last association will not generate any
selectFragment, then the implementation adds an extraneous ", " to the
Looking forward to your feedback and working together to get this into
the tree. Need info about test cases to create, documentation etc.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 22830 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/hibernate-dev/attachments/20081214/48d305cb/attachment.bin
More information about the hibernate-dev