[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3646?page=c...
]
David Mansfield updated HHH-3646:
---------------------------------
Attachment: 0003-implement-criteria-query-of-collection-of-component-.patch
0002-throw-a-better-exception-if-an-attempt-is-mado-to-pu.patch
0001-only-prepend-the-a-comma-when-we-definitely-have-a-s.patch
patches 1-3 (of 5) for patching against 3.5.0-Beta-3
see next set of attachments for patches 4-5.
Patch 0001: In the JoinWalker, we assemble an SQL select list fragment
from a list of Joinables. Reading the existing code, we see it's
possible for the fragment generated to be empty. However if the LAST
joinable generates an empty fragment, we put a spurious comma into the
fragment. Fix this by only prepending a comma when necessary.
Patch 0002: In the CriteriaQueryTranslator, we process the path given by
a SubCriteria object looking for the entity name for the property. If
the SubCriteria was mistakenly created on a component type, we will exit
the loop using the owning entity, and will eventually end up failing
(throwing an exception) trying to lookup up the restricted property
against the entity, instead of against the component. Fix this by
throwing a more informative exception, and modify the documentation to
be explicit about how to do this properly.
Patch 0003: Implement the enhancement named. This includes the
documentation changes. The general approach is:
- create an interface called the CriteriaInfoProvider which abstracts
the operations that are different for the different types of Criteria
targets.
- change the getPathEntityName method to be a factory method for
creating the proper implementation of the interface
- change the rest of CriteriaQueryTranslator to use the interface
instead of using the previous entity-only implementation
- implementations of the interface exist for
Entity: this implements the same code as currently exists
ComponentCollection: for collection-of-component
ScalarCollection: for collection-of-value
Component: for components
- update the logic in CriteriaJoinWalker which has to be very careful
about how it works since the walker walks certain property paths twice.
implement Criteria API querying of collection-of-component
----------------------------------------------------------
Key: HHH-3646
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3646
Project: Hibernate Core
Issue Type: Patch
Components: query-criteria
Affects Versions: 3.2.6
Environment: hibernate 3.2.6, tested on linux 64-bit openjdk 1.6 (jdk1.5 for
compiling). mapping created under annotations 3.3.1ga
Reporter: David Mansfield
Attachments: 0001-only-prepend-the-a-comma-when-we-definitely-have-a-s.patch,
0002-throw-a-better-exception-if-an-attempt-is-mado-to-pu.patch,
0003-implement-criteria-query-of-collection-of-component-.patch,
0004-implement-a-test-case-for-query-collection-of-value.patch,
0005-implement-a-test-case-for-query-collection-of-compon.patch,
hib-core-query-collection-of-elements-3_2_6-ver2.patch,
hib-core-query-collection-of-elements-3_2_6.patch,
hib-core-query-collection-of-elements-3_3_1-ver5.patch,
hib-core-query-collection-of-elements-3_3_1-ver6.patch
Original Estimate: 1 day
Remaining Estimate: 1 day
the attached patch implements a first cut, extremely rough, yet working extension of the
CriteriaQueryTranslator class to allow for querying of properties of components inside a
collection, or querying properties of associated elements of components inside a
collection. eg for
* code is lightly tested, this example is for illustrative purposes only
* i use annotations, so my example is expressed in those terms, and i've only tested
with mappings generated via annotations, however, the modifications only apply to the
core.
@Entity
class Order {
@Id
String id;
@CollectionOfElements
Set<OrderLineItem> lineItems;
}
@Embeddable
class OrderLineItem {
@ManyToOne
Product product;
Integer quantity;
}
@Entity
class Product {
String name;
}
Then we can now do:
Criteria c = session.createCriteria(Order.class)
.createCriteria("lineItems")
.add(Restrictions.gt("quantity", new Integer(1))
.list();
or
Criteria c = session.createCriteria(Order.class)
.createCriteria("lineItems")
.createCriteria("product")
.add(Restrictions.like("name", "cake%")
.list();
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira