-->
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.  [ 2 posts ] 
Author Message
 Post subject: Help: query return wrong arraylist
PostPosted: Wed Feb 24, 2010 8:33 am 
Newbie

Joined: Tue Apr 14, 2009 4:40 am
Posts: 5
[b]Hibernate version:3.1[/b]
Hi to all,
I have a mysql view, that make a join bewteen 2 tables (mysql).
When I launch a query by java-hibernate on this view, the code generated is correct (read with debug in the java console) and returns a correct arraylist of objects.
But the criteria list (crit.list()) return a wrong arraylist of objects, where the last object is incorrect (it repeats the previus object in the list)
the code in java is:

public List<TheObjectViewObj> searchObjectsByPeriod(MyObjectObj myObject, Date startDate, Date endDate) {
Session s = HibernateUtil.currentSession();
s.clear();
ArrayList<TheObjectViewObj> result = new ArrayList<TheObjectViewObj>();
Criteria crit = s.createCriteria(TheObjectViewObj.class);

if((myObject.getCodice()!=null)&&(!myObject.getCodice().toString().trim().equals(""))){
crit.add(Restrictions.eq("codObject", myObject.getCode()));
}
crit.add(Restrictions.ne("status", IConstants.STATUS_01));
//crit.add(Restrictions.or(Restrictions.between("date",startDate,endDate ),Restrictions.isNull("date")));
crit.add(Restrictions.between("date",startDate,endDate ));
crit.addOrder(Order.asc("date"));
result.addAll(crit.list());
return result;
}

How is it possible?
This is the only query I have with this problem.
Thanks in advance


Top
 Profile  
 
 Post subject: Re: Help: query return wrong arraylist
PostPosted: Wed Feb 24, 2010 10:50 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Suggerimento: Prova con versione Hibernate3.3.2GA (oppure Hibernate 3.5.0-CR1).
Se il problema persiste, apri und issue su Hiberntate JIRA (con test-case).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.