-->
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.  [ 1 post ] 
Author Message
 Post subject: 2 queries in a row produce an exception
PostPosted: Fri Aug 26, 2005 5:03 pm 
Newbie

Joined: Sun Aug 21, 2005 11:36 am
Posts: 6
Hi,

I am experiencing a behavior by which 2 queries (one by HQL the other by Criteria) work if done independently, that is if I comment either it works, yet if run one after the other as written in the code, it produces the exception indicated.

I have tried looking at the documentation and forum for similar issues but could not find any.

Thanx in advance for any clue,
Jean Safar

3.0:

Mapping documents:

public static void queryTrades (Session session) {
// Object o = session.get("faketrade.test.FakeTrade", new Long(500));
// System.out.println ("Got Object for ID 500: " + o);
Query q = session.createQuery("from FakeTrade t where t.type = :type");
q.setString("type","CONVERTIBLE");
List l = q.list();

System.out.println ("Got Query " + q + " Result " + l.size() + " Objects for type CONVERTIBLE");
Criteria c = session.createCriteria("faketrade.test.FakeTrade");
c.add(Expression.eq("type", "CONVERTIBLE"));
l = c.list();
System.out.println ("Got Criteria " + c + " Result " + l.size() + " Objects for type CONVERTIBLE");
}:


Exception in thread "main" org.hibernate.HibernateException: identifier of an instance of faketrade.test.FakeTrade altered from 253 to 0
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:51)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:82)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:39)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:711)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1315)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at com.quartetfs.hibtest.Main.queryTrades(Main.java:51):


MySql 4:


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

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.