This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes How to use two table in criterion in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "How to use two table in criterion in hibernate" Watch "How to use two table in criterion in hibernate" New topic
Author

How to use two table in criterion in hibernate

Bhupendra Dubey
Greenhorn

Joined: May 10, 2011
Posts: 6
how to use crterion with two table ??please help me

Criteria criteria=ss.createCriteria(AppDTO1.class, "m1");
criteria.createCriteria(AppDTO2.class, "m2");

criteria.setFetchMode("AppDTO2", FetchMode.JOIN);
criteria.add(Restrictions.eq("m1.category", "COMBINE"));

ProjectionList projectionList1=Projections.projectionList();
projectionList1.add(Projections.property("m1.category"));
projectionList1.add(Projections.property("m1.ag_contract"));
//m2.CATEGORY, m2.MODEL_SERIES, m2.MPI_MODEL, m2.MACHINE_NAME, m2.YEAR_OUT_PROD
projectionList1.add(Projections.property("m2.appDTO2ID.CATALOG_MODEL_ID"));
projectionList1.add(Projections.property("m2.appDTO2ID.PARTS_CATALOG_NUM"));
projectionList1.add(Projections.property("m2.appDTO2ID.MODEL_NAME_LABEL"));
projectionList1.add(Projections.property("m2.CATEGORY"));
projectionList1.add(Projections.property("m2.MODEL_SERIES"));
.
.

and i am getting error
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use two table in criterion in hibernate
 
Similar Threads
Synchronized Lists
Problem with Hibernate Criteria, Projections and associations
Retrieve collections using projections
I get a ClassCastException
hibernate joining two tables