-->
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.  [ 3 posts ] 
Author Message
 Post subject: cannot insert NULL into ID
PostPosted: Thu Mar 16, 2006 3:12 pm 
Newbie

Joined: Thu Mar 16, 2006 2:55 pm
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0

Mapping documents:
<class name="com.abc.performance.UserAppraisalData" table="USER_APPRAISAL_RESPONSES" lazy="false">
<id column="ID" name="id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<discriminator column="RESPONSE_TYPE" type="string"/>
<timestamp column="LAST_MODIFIED_TS" name="lastModifiedTS"/>
<many-to-one name="user" class="com.abc.security.User" column="USER_ID" not-null="true" outer-join="true" lazy="true"/>
<many-to-one name="appraisal" class="com.abc.performance.PerformanceAppraisal" column="APPRAISAL_ID" not-null="true" lazy="false"/>
<many-to-one name="status" class="com.abc.performance.WorkflowStep" column="STATUS_ID" not-null="true" lazy="false"/>
<property column="SECTION_ID" length="10" name="pageSectionId" type="long"/>
<subclass name="com.abc.performance.UserAppraisalCart" discriminator-value="UserAppraisalCart" lazy="false">
<property column="RESPONSE_WEIGHT" length="10" name="inCart" type="long"/>
<many-to-one name="section" class="com.abc.performance.ReviewTemplatePageSection" column="RESPONSE_ID" outer-join="false" not-null="true" lazy="true"/>
<property column="RESPONSE_ID" length="10" name="sectionId" type="long" insert="false" update="false"/>
<property column="GOAL_COMP_ID" length="10" name="goalCompId" type="long"/>
</subclass>

<subclass name="com.abc.performance.UserAppraisalSignature" discriminator-value="UserAppraisalSignature" lazy="false">
<property column="RESPONSE_VALUE" length="50" name="signature" type="string"/>
</subclass>

<subclass name="com.abc.performance.UserAppraisalRating" discriminator-value="UserAppraisalRating" lazy="false">
<many-to-one name="formula" class="com.abc.performance.Formula" column="RESPONSE_ID" not-null="true" outer-join="false" lazy="false"/>
<property column="RESPONSE_WEIGHT" length="10" not-null="true" name="ratingValue" type="double"/>
<property column="RESPONSE_ID" length="10" name="formulaId" type="long" insert="false" update="false"/>
</subclass>

<subclass name="com.abc.performance.ManagerSelectedCompetency" discriminator-value="ManagerSelectedCompetency" lazy="false">
<many-to-one name="section" class="com.abc.performance.ReviewTemplatePageSection" column="RESPONSE_ID" outer-join="false" not-null="true" lazy="true"/>
<set name="managerCompetencies" table="KCT_SECTION_MANAGER_COMPETENCY" lazy="false">
<key column="SECTION_ID"/>
<many-to-many class="com.abc.common.Competency" column="COMPETENCY_ID"/>
</set>
</subclass>

<subclass name="com.abc.performance.UserResponse" discriminator-value="UserResponse" lazy="false">
<property column="GOAL_COMP_ID" length="10" name="goalCompId" type="long"/>
<property column="IS_ADHOC_RESPONSE" length="1" name="isAdhocResponse" not-null="true" type="true_false"/>
<many-to-one name="response" class="com.abc.performance.SectionResponse" column="RESPONSE_ID" not-null="true" outer-join="false" lazy="false"/>
<property column="RESPONSE_ID" length="10" name="responseId" type="long" insert="false" update="false"/>
<subclass name="com.abc.performance.UserAppraisalResponse" discriminator-value="UserAppraisalResponse" lazy="false">
<property column="RESPONSE_VALUE" length="500" name="responseValue" type="string"/>
<set name="ratingValues" inverse="true" outer-join="true" cascade="all-delete-orphan" lazy="true">
<key column="USER_APPRAISAL_RESPONSE_ID"/>
<one-to-many class="com.abc.performance.UserResponseRatingValue"/>
</set>
</subclass>

<subclass name="com.abc.performance.UserAppraisalResponseWeight" discriminator-value="UserAppraisalResponseWeight" lazy="false">
<property column="RESPONSE_WEIGHT" length="10" not-null="true" name="responseWeight" type="long"/>
</subclass>
</subclass>
</class>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
ORACLE 9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I am randomly getting

cannot insert NULL into ("TEST"."USER_APPRAISAL_RESPONSES"."ID")


Top
 Profile  
 
 Post subject: cannot insert NULL into ID
PostPosted: Thu Mar 16, 2006 4:27 pm 
Newbie

Joined: Tue Mar 07, 2006 11:34 am
Posts: 2
I think this occur because you defined the id to be of type "long" which in Java is a primitive. In this case, a non-saved value could be 0 but not null.
If you need it to be null you should consider to define it as "Long". This way, Java can make it null.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 8:36 pm 
Newbie

Joined: Thu Mar 16, 2006 2:55 pm
Posts: 2
Thanks for the reply..

if that's the case, i should get error every time, but i am getting error ramdomly..


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