posted 13 years ago
Hi James,
Thank you very more for your response. Here some more detail to my problem:
I have 53 tables connected to each other using annotations. All theses tables hold different information about an instructor, meaning the instructor class is the top level class. In a specific circumstance I need to fetch all the information about an instructor from the database, so I user join fetching. Here the code of the fetch function I have reached so far:
public instructor retrieveInst(instructor inst){
List<instructor> retrievedInstructors = new ArrayList<instructor>();
Session ss = hibernateUtil.getSession();
Transaction tx = ss.beginTransaction();
Criteria crit = ss.createCriteria(instructor.class);
crit.add(Restrictions.eq("index", inst.Index));
crit.setFetchMode("nationality", FetchMode.JOIN);
crit.setFetchMode("birthGov", FetchMode.JOIN);
crit.setFetchMode("acCard", FetchMode.JOIN);
crit.setFetchMode("als", FetchMode.JOIN);
crit.setFetchMode("aw", FetchMode.JOIN);
crit.setFetchMode("collRes", FetchMode.JOIN);
crit.setFetchMode("dt", FetchMode.JOIN);
crit.setFetchMode("diss", FetchMode.JOIN);
crit.setFetchMode("externalExp", FetchMode.JOIN);
crit.setFetchMode("fixationAnnReports", FetchMode.JOIN);
crit.setFetchMode("fixCard", FetchMode.JOIN);
crit.setFetchMode("govServs", FetchMode.JOIN);
crit.setFetchMode("specMixServs", FetchMode.JOIN);
crit.setFetchMode("internalActs", FetchMode.JOIN);
crit.setFetchMode("nonPromResearches", FetchMode.JOIN);
crit.setFetchMode("promResearches", FetchMode.JOIN);
crit.setFetchMode("raises", FetchMode.JOIN);
crit.setFetchMode("reports", FetchMode.JOIN);
crit.setFetchMode("retCard", FetchMode.JOIN);
crit.setFetchMode("seminars", FetchMode.JOIN);
crit.setFetchMode("socServices", FetchMode.JOIN);
crit.setFetchMode("supervisedRes", FetchMode.JOIN);
crit.setFetchMode("upperStudCard", FetchMode.JOIN);
crit.setFetchMode("vacations", FetchMode.JOIN);
crit.setFetchMode("partner", FetchMode.JOIN);
crit.setFetchMode("children", FetchMode.JOIN);
crit.setFetchMode("otherRelations", FetchMode.JOIN);
crit.setFetchMode("instructorsDataAddUpdateEvents", FetchMode.JOIN);
crit.setFetchMode("iDS", FetchMode.JOIN);
crit.setFetchMode("acCard.instCerts", FetchMode.JOIN);
crit.setFetchMode("acCard.instSintDeg", FetchMode.JOIN);
crit.setFetchMode("nationality.nationalityInstructors", FetchMode.JOIN);
crit.setFetchMode("DetailedSpecialization.instCerts", FetchMode.JOIN);
crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
retrievedInstructors = crit.list();
instructor retrievedInst = retrievedInstructors.get(0);
tx.commit();
ss.close();
return retrievedInst;
}
Now consider the following situation:
An instructor may have more than one promotion research, meaning the instructor class incorporates a set of promotion researches. A promotion research instance contains a general specialization object, which in turn has a number of lists in it. How can I set join fetch for these lists without putting it in the annotation?
A simpler solution for me is if I could set join fetch for the entire instructor (the whole object tree) in just one command instead of needing to set join fetch for each object or set inside the instructor.
Fast help would be very appreciated, since I need to deliver the project on Friday, and google didn't help me any further.