*
The moose likes Object Relational Mapping and the fly likes Hibernate Criteria For Child One-To-Many Relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Criteria For Child One-To-Many Relationship" Watch "Hibernate Criteria For Child One-To-Many Relationship" New topic
Author

Hibernate Criteria For Child One-To-Many Relationship

bagus winarno
Greenhorn

Joined: Apr 29, 2013
Posts: 2
Hi,
I have relation one to many table like this
CUSTOMER(ID, NAME, ADDRESS) ONE-TO-MANY ORDER(ID,ID_PRODUCT, DATE)

this is my sql code = "SELECT * FROM CUSTOMER LEFT JOIN ORDER ON CUSTOMER.ID=ORDER.ID WHERE ID_PRODUCT LIKE '001' "
If I use DetachCriteria how I can write the criteria correctly


DetachedCriteria crit = DetachedCriteria.forClass(getDomainClass());

/**How can I write the criteria here**/

crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

Thanks for your help.


[Thumbnail for menggunakan createCriteria HQL.png]

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate Criteria For Child One-To-Many Relationship
 
Similar Threads
Using Oracle squence in Hibernate
Designing in Hibernate
how to write the jpql to query against the one to many table
session take older value
Transposing rows to columns