Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1.1
Name and version of the database you are using:MySql 5.0
Hi guys,
My query is like below:
Code:
<query name="findPostingDetailsByCategoryAndCity"><![CDATA[
from PostingDetails as pid left join pid.lessorAddress as addr right join pid.categorizedItems as ci where addr.city = ? and ci.id.categoryId = ?
]]></query>
and my class is like below:
Code:
public abstract class PostingDetails implements Serializable{
private Set lessorAddress = new HashSet();
private Set categorizedItems = new HashSet();
}
In the DAO implementation,
Code:
public List findPostingDetails(Long categoryId, String city){
List list = getHibernateTemplate().findByNamedQuery(
"findPostingDetailsByCategoryAndCity",
new Object[] { city , categoryId });
if (list.size() < 1)
return null;
return list;
}
In my unit test:
public void testGetPosting(){
List <PostingDetails> list = postMgr.findPostingDetails(new Long(8574),"Houghton");
for(PostingDetails element : list){
System.out.println("title = "+element.getTitle());
}
}
and I got java.lang.ClassCastException. It shouldn't be class cast exception as I am querying the main class (PostingDetails). Pls help, Thanks !