-->
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.  [ 1 post ] 
Author Message
 Post subject: one-to-many mapping versucht null-value einzufügen
PostPosted: Tue Oct 23, 2007 5:31 pm 
Newbie

Joined: Tue Oct 23, 2007 5:02 pm
Posts: 5
Hi, ich bin langsam am verzweifeln.
Folgende Situation.

Ich habe ein eindimensionales one-to-many mapping zwischen der Klasse Vertrag und Bestellungen.

Das Mapping im Vertrag sieht so aus:
<map name="orders" lazy="false" cascade="all">
<key column="part_id" />
<map-key column="order_identifier" type="string" ></map-key>
<one-to-many class="de.test.contractadministration.model.Order"/>
</map>

DIe Contract- Klasse hat also eine Map von Order-Objekten.
Wenn ich dies jetzt speicher mit

Session session = getCurrentSession();
Transaction trans = session.beginTransaction();


session.saveOrUpdate(contract);

try {
trans.commit();
} catch (Throwable t) {
logger.error("Error saving Contract ", t);
trans.rollback();

}

funktioniert das beim ersten Mal, sobald HIbternate aber ein Objekt bekommt, welches schon in der Datenbank vorhanden ist bekomme ich

org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at de.test.contractadministration.persistence.dao.impl.HibernateContractDAOImpl.addContract(HibernateContractDAOImpl.java:86)
at de.test.contractadministration.persistence.jobs.SaveContractJob.run(SaveContractJob.java:21)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 update resource_orders set part_id=null, order_identifier=null where part_id=jk wurde abgebrochen. Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2534)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1317)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2596)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 10 more

Klar, er versucht, einen null-value in eine Primärschlüsselspalte einzufügen, was ich einfach nicht verstehe ist, warum er überhaupt versucht einen Null-Value einzufügen.

resource_orders set part_id=null, order_identifier=null where part_id=jk

Was soll das?

Viele Grüße

sps


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.