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:
|