Transaction marked as rollbackOnly?

179 views
Skip to first unread message

nino martinez wael

unread,
Apr 29, 2010, 5:14:15 AM4/29/10
to warp...@googlegroups.com
Hi

I have a dao class which looks something like this:

@JpaUnit
@Transactional
public class PhoneJPADao implements PhoneDao {

...
@Override
@Transactional(exceptOn = SQLException.class)
public List<Pilot> findPilots(int from, int count, String sortProperty,
boolean sortAsc, SearchCriteriaPilot searchCriteriaPilot) {
logger.debug("findPilots");
Query query = getEntityManager().createQuery(
"select p from " + Pilot.class.getSimpleName() + " p "
+ searchCriteriaPilot.getJPASnipplet() + " order by p."
+ sortProperty + " " + getAscOrDesc(sortAsc));

query.setFirstResult(from);
query.setMaxResults(count);
try {
List resultList = query.getResultList();
for (Object object : resultList) {
getEntityManager().refresh(object);
}
return resultList;
} catch (Exception e) {
return Collections.emptyList();
}
}
...

Now above contains a like criteria and in some cases it will throw an
error about fetch first because the statement returned 0 rows, I
havent found out howto turn off fetch first. Thats why I am catching
the exception and are returning an empty list. However warp persist
will mark the method bad thus the method never suceeds.. I have tried
removing the annotation from the method but that does not help and
removing the annotation from the class is not an option.

What should I do?

regards Nino

--
You received this message because you are subscribed to the Google Groups "warp-core" group.
To post to this group, send email to warp...@googlegroups.com.
To unsubscribe from this group, send email to warp-core+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/warp-core?hl=en.

nino martinez wael

unread,
Apr 29, 2010, 5:14:43 AM4/29/10
to warp...@googlegroups.com
Forgot to mention I am using the 2009 snapshot for guice 2.0

2010/4/29 nino martinez wael <nino.mart...@gmail.com>:

nino martinez wael

unread,
Apr 29, 2010, 5:34:11 AM4/29/10
to warp...@googlegroups.com
Hmm "solved" it by checking for row counts before calling the real search..

Dhanji R. Prasanna

unread,
Apr 29, 2010, 6:06:47 AM4/29/10
to warp...@googlegroups.com
Sounds reasonable as a fix.

Dhanji.

On Thursday, April 29, 2010, nino martinez wael
Reply all
Reply to author
Forward
0 new messages