-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Newbie left join issue
PostPosted: Thu May 27, 2010 4:29 pm 
Newbie

Joined: Mon May 10, 2010 1:41 pm
Posts: 15
The following works:
String hql = "select new map(log as log, cur as cur) " +
" from db2.co99blh.Dtnamelog log, " +
" db2.co99blh.Dtname cur " +
" where " +
" (log.id.mlid = cur.id.mid and " +
" log.id.mlgroup = cur.id.mgroup) " +
" order by log.mlco";

But when I try to change the above to use a left join.
nullorg.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44) org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38) org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1358) org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathEntityName(CriteriaQueryTranslator.java:204) org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:191) org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:81) org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:58) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550) org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) utilities.ListChangedCompanyNames2.query(ListChangedCompanyNames2.java:82)

Right now I was trying with a Criteria, so here is the code from that:
Criteria crit = session.createCriteria("db2.co99blh.Dtnamelog", "log");
crit.createAlias("Dtname", "cur", Criteria.LEFT_JOIN);
crit.add(Restrictions.eqProperty("log.id.mlid", "cur.id.mid"));
crit.add(Restrictions.eqProperty("log.id.mlgroup", "cur.id.mgroup"));
crit.setMaxResults(resultsPerPage);
crit.setFirstResult(startRecord);
list = crit.list(); //Exception thrown here (ListChangedCompanyNames2.java:82)

I've seen some reference that I might need to do something in the mapping files to enable left joins... I have no idea, as long as I don't use joins everything works fine, but in this case I definitely need all the elements in the left table and generating a cross product bothers me.


Top
 Profile  
 
 Post subject: Re: Newbie left join issue
PostPosted: Fri May 28, 2010 2:08 pm 
Newbie

Joined: Mon May 10, 2010 1:41 pm
Posts: 15
I don't know why I have such issues with joins and hibernate, is there a tutorial someone can recommend for this issue?

Perhaps using a mysql db (I am using DB2 but anything is better than nothing) and describing the process from table mapping to using the join? Even better start with table creation in mysql, then table mapping, and then using the join... That would be really ideal.


Top
 Profile  
 
 Post subject: Re: Newbie left join issue
PostPosted: Mon May 31, 2010 5:02 pm 
Newbie

Joined: Mon May 10, 2010 1:41 pm
Posts: 15
Okay I obviously don't know what I'm doing if I can't get a join working...

What is the best hibernate reference out there right now?
What is the best hibernate tutorial out there?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.