-->
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.  [ 10 posts ] 
Author Message
 Post subject: JDBCException: Could not execute JDBC batch
PostPosted: Thu Feb 12, 2004 9:58 am 
Newbie

Joined: Thu Feb 12, 2004 9:48 am
Posts: 12
Location: Campina Grande, PB, Brazil
Greetings.


I have a problem and I need help.
I


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 10:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Have you set hibernate.jdbc.batch_size=0 ? Also there must be a more detailed message, try finding the root cause of the exception.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 10:43 am 
Newbie

Joined: Thu Feb 12, 2004 9:48 am
Posts: 12
Location: Campina Grande, PB, Brazil
[quote="gloeglm"]Have you set hibernate.jdbc.batch_size=0 ? Also there must be a more detailed message, try finding the root cause of the exception.[/quote]

Thanks for the quick reply, gloeglm.

The root cause in the stack trace is:

[code]
Caused by: java.sql.BatchUpdateException: Invalid argument value: Duplicate entry '2' for key 1
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 10:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I suspect you are forgetting to set your parent reference in the child object, like this:

Code:
pessoa.getCaixas().add( caixaEntrada );
caixaEntrada .setPessoa(pessoa);


If this does not fix it, please show more of your mapping, eg. the class and id parts of it, too.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 10:57 am 
Newbie

Joined: Thu Feb 12, 2004 9:48 am
Posts: 12
Location: Campina Grande, PB, Brazil
[quote="gloeglm"]
I suspect you are forgetting to set your parent reference in the child object, like this:

[code] pessoa.getCaixas().add( caixaEntrada );
caixaEntrada .setPessoa(pessoa);[/code]

If this does not fix it, please show more of your mapping, eg. the class and id parts of it, too.[/quote]

The code for Pessoa:

[code]
/**
* Represents a person
* @author J


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 11:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hi, I meant show your mappings :) Please try to remove propertys and stuff which is not involved. And please check the generated SQL, probebly you can give us more info on what is going wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 11:20 am 
Newbie

Joined: Thu Feb 12, 2004 9:48 am
Posts: 12
Location: Campina Grande, PB, Brazil
[quote="gloeglm"]Hi, I meant show your mappings :) Please try to remove propertys and stuff which is not involved. And please check the generated SQL, probebly you can give us more info on what is going wrong.[/quote]

Sorry. Well, here are the mappings:

[code]<hibernate-mapping schema="balcomMessenger" auto-import="true">

<class name="br.com.balcom.messenger.bean.Pessoa" table="PESSOA" lazy="true" >

<id name="id" type="integer"
column="ID" unsaved-value="null" access="property">
<generator class="native">
</generator>
</id>

<property
name="nome"
column="NOME"
type="string"
update="true"
insert="true"
access="property"
/>

<property
name="senha"
column="SENHA"
type="string"
update="true"
insert="true"
access="property"
/>

<list
name="caixas"
lazy="true"
cascade="delete"
access="property">

<key column="ID_PESSOA" />
<index type="java.lang.Integer" column="ID"/>
<one-to-many class="br.com.balcom.messenger.bean.CaixaDeMensagens" />
</list>

</class>

</hibernate-mapping>

<hibernate-mapping schema="balcomMessenger" auto-import="true">

<class name="br.com.balcom.messenger.bean.CaixaDeMensagens" table="CX_MENSAGENS" lazy="true" >

<id name="id" type="integer" column="ID" unsaved-value="null" access="property">
<generator class="native">
</generator>
</id>

<property
name="tipo"
column="TIPO"
type="integer"
update="true"
insert="true"
access="property"
/>

<many-to-one
name="dono"
column="ID_PESSOA"
/>

<list
name="mensagens"
table="MENSAGEM_CAIXA"
lazy="true"
cascade="delete"
access="property">

<key column="ID_CAIXA"/>
<index column="ID" type="integer"/>
<many-to-many
column="ID_MENSAGEM"
class="br.com.balcom.messenger.bean.Mensagem"
/>

</list>

</class>

</hibernate-mapping>[code][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 11:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hm, this looks fine to me so far ... what SQL is generated, and what constraint is violated? Enable logging and check the log.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:06 pm 
Newbie

Joined: Thu Feb 12, 2004 9:48 am
Posts: 12
Location: Campina Grande, PB, Brazil
gloeglm wrote:
Hm, this looks fine to me so far ... what SQL is generated, and what constraint is violated? Enable logging and check the log.


Quote:
Well, I never did logging before. How can I do that?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
http://www.hibernate.org/119.html#A15


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