-->
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: Could not execute JDBC batch update
PostPosted: Tue Mar 02, 2004 1:34 am 
Beginner
Beginner

Joined: Thu Feb 05, 2004 10:39 pm
Posts: 44
Ok, I am getting some exceptions with a many to many relationship. Hibernate 2.1.1 with MySQL on Windows running on WebSphere.

Here is the exception:
Code:
java.sql.BatchUpdateException: General error,  message from server: "Column 'elementReferenceID' cannot be null"


Here is the SQL that hibernate executes:
Code:
insert into Relationship (lastModified, elementReferenceID, name, parentRelationship, type, deleted, instanceClass, relationshipID) values (?, ?, ?, ?, ?, ?, 'ManyToManyRelationship', ?)
insert into ElementReference (elementClass, elementName, elementDescription, element, elementID, referenceID) values (?, ?, ?, ?, ?, ?)
update Relationship set lastModified=?, elementReferenceID=?, name=?, parentRelationship=?, type=?, deleted=? where relationshipID=? and lastModified=?
insert into manytomany_elements (relationshipID, elementReferenceID) values (?, ?)
SQL Error: 1048, SQLState: S1000
General error,  message from server: "Column 'elementReferenceID' cannot be null"


Here are my mappings:

<hibernate-mapping>
<class
name="com.forisent.framework.productManager.productOrganizer.store.entity.OneToManyRelationship"
table="Relationship"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="OneToManyRelationship"
>

<id
name="ID"
column="relationshipID"
type="java.lang.String"
length="32"
unsaved-value="none"
>
<generator class="uuid.hex">
</generator>
</id>

<discriminator
column="instanceClass"
type="string"
/>

<timestamp
name="lastModified"
column="lastModified"
/>

<many-to-one
name="element"
class="com.forisent.framework.productManager.productOrganizer.store.ElementReference"
cascade="all"
outer-join="auto"
update="true"
insert="true"
column="elementReferenceID"
not-null="false"
/>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name"
/>

<many-to-one
name="parentRelationship"
class="com.forisent.framework.productManager.productOrganizer.store.Relationship"
cascade="all"
outer-join="auto"
update="true"
insert="true"
column="parentRelationship"
/>

<set
name="subRelationships"
lazy="false"
inverse="true"
cascade="all"
sort="unsorted"
>

<key
column="parentRelationship"
/>

<one-to-many
class="com.forisent.framework.productManager.productOrganizer.store.entity.OneToManyRelationship"
/>
</set>

<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="type"
/>

<property
name="deleted"
type="java.util.Date"
update="true"
insert="true"
column="deleted"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OneToManyRelationship.xml
containing the additional properties and place it in your merge dir.
-->
<subclass
name="com.forisent.framework.productManager.productOrganizer.store.entity.ManyToManyRelationship"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="ManyToManyRelationship"
>

<set
name="elements"
table="manytomany_elements"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
>

<key
column="relationshipID"
/>

<many-to-many
class="com.forisent.framework.productManager.productOrganizer.store.ElementReference"
column="elementReferenceID"
outer-join="auto"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ManyToManyRelationship.xml
containing the additional properties and place it in your merge dir.
-->

</subclass>

</class>

The column in question is bolded.

finally, here is my code being called:
Code:
try{
         session = _SessionFactory.openSession();
         tx = session.beginTransaction();
         try{
                  
            session.saveOrUpdate(obj);   
            //session.flush();
            
         }catch(HibernateException e){
            if(tx != null) tx.rollback();
            log.error("Rolling Back Persist Operation");
         }
         
         if(tx != null) tx.commit();
         
      }catch(HibernateException e){
         throw new PersistenceException(e.getMessage(), e);
      }finally{
         try{
            if(session != null) session.close();
         }catch(HibernateException e){
            throw new PersistenceException(e.getMessage(), e);
         }
      }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 2:20 am 
Beginner
Beginner

Joined: Thu Feb 05, 2004 10:39 pm
Posts: 44
oh, the changes are actually made in the DB so it all seems to work but I still get the exception.


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.