wood burning stoves 2.0*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
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
Retrieve collections using projections
Problem with Hibernate Criteria, Projections and associations
I get a ClassCastException
hibernate joining two tables