[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3646?page=c...
]
Sergey Pulyaev commented on HHH-3646:
-------------------------------------
There is a problem if we have Many-To-Many collection.
In this situation function CriterionJoinWalker.generateTableAlias is called twice - for
reference table and then - for destination table,
so there will be two aliases with the same name in query - and it will crush with error:
Caused by: java.sql.SQLException: The correlation name '111' is specified multiple
times in a FROM clause.
Sample SQL generated:
select
this_.id as y0_,
sr1_.id as y1_
from
roles this_
inner join
role_inheritors sr1_
on (
this_.id=sr1_.role_id
)
inner join
roles sr1_
on (
sr1_.inherit_id=sr1_.id
)
where
this_.id<>sr1_.id
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: hib-core-query-collection-of-elements-3_2_6-ver2.patch,
hib-core-query-collection-of-elements-3_2_6.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