-->
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: Problem with HQL query: identifier altered from 100 to 100??
PostPosted: Wed Jul 21, 2004 7:26 pm 
Newbie

Joined: Wed Jun 16, 2004 11:20 am
Posts: 6
I have a simple class, lets say MyClass, with a reference inside to another MyClass instance called "parent".

When I try to query for all MyClass instances with a null parent, I get this exception: HibernateSystemException: identifier of an instance of MyClass altered from 100 to 100.

My query looks like: "from MyClass mc where mc.parent is null"

My hibernate version is Hibernate 2.1.3.

In my test, I have two instances of MyClass in the database, with ids of 100 and 101, and parent values of null. Nothing else is going on in the database.

I don't quite understand this exception. I tried searching the forum for similar exceptions, but I couldn't find anything. If anyone could shed any light on this, I would appreciate it. Thanks :)

my mapping
Code:
    <class name="MyClass" table="my_class">
        <id name="id" column="id" type="int" unsaved-value="-1">
            <generator class="assigned"/>
        </id>
        <property name="name" column="name" not-null="true"/>
        <many-to-one
            name="parent"
            class="MyClass"
            column="parent_id"
        />
    </class>


the exception
Code:
org.springframework.orm.hibernate.HibernateSystemException: identifier of an instance of MyClass altered from 100 to 100; nested exception is net.sf.hibernate.HibernateException: identifier of an instance of MyClass  altered from 100 to 100 net.sf.hibernate.HibernateException: identifier of an instance of MyClass altered from 100 to 100 at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2631) at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2454) at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2447) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2249) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228) at org.springframework.orm.hibernate.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:202) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:151) at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170) at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:328) at


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 10:07 pm 
Newbie

Joined: Wed Jun 16, 2004 11:20 am
Posts: 6
I figured it out. I have my class's id declared as a long and the hbm mapping as an int. OOPS.


I attached a debugger to my vm session and found this out the hard way :)


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.