-->
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: Exception while inserting values
PostPosted: Wed Apr 23, 2008 6:05 am 
Newbie

Joined: Wed Apr 23, 2008 5:32 am
Posts: 1
Hi,
I am new and working with the tutorial(http://www.hibernate.org/hib_docs/v3/re ... orial.html)..

I created Events table in oracle and my Event.hbm.xml is

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.novell.sankar.hibernate.test.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native">
<!-- <param name="sequence">queue_sequence</param> -->
</generator>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
</hibernate-mapping>

I inserted values through hibernate and able to list the values ...
Then i manually entered values in oracle and able to list the values

But i got exeception while trying to insert values after manullay inserted values in oracle..

15:21:07,968 ERROR JDBCExceptionReporter:78 - ORA-00001: unique constraint (WORKS.SYS_C0027956) violated

15:21:07,968 WARN JDBCExceptionReporter:77 - SQL Error: 1, SQLState: 23000
15:21:07,968 ERROR JDBCExceptionReporter:78 - ORA-00001: unique constraint (WORKS.SYS_C0027956) violated

15:21:07,968 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
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:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
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 com.novell.sankar.hibernate.test.EventManager.createAndStoreEvent(EventManager.java:49)
at com.novell.sankar.hibernate.test.EventManager.main(EventManager.java:17)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (ZENWORKS.SYS_C0027956) violated

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:602)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9350)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:210)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 9 more
Exception in thread "main" 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:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
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 com.novell.sankar.hibernate.test.EventManager.createAndStoreEvent(EventManager.java:49)
at com.novell.sankar.hibernate.test.EventManager.main(EventManager.java:17)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (ZENWORKS.SYS_C0027956) violated

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:602)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9350)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:210)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 9 more


my question is after manually entering values in oracle whether the hibernate won't update the counter(event_id) values in session??


Then ..i recreated the table and manually inserted the values thn i tried to insert values through hibernate then also i got the same error..

Pls explain me the behaviour of hibernate.....


Regards
Sankar..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 3:26 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
In oracle, there are associated sequences to every auto incremental primary key. After manually inserting the data in your database... Did you increment the sequence value? The exception clearly states unique constraint violated. Try incrementing the sequence manually every time you do a manual data entry.

_________________
Sukirtha


Top
 Profile  
 
 Post subject: data schema
PostPosted: Thu Apr 24, 2008 4:19 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
Hi,
1. could you pls also post the entire oracle DDL that you used?
2. try letting hibernate create the db schema using its own generated DDL, and compare it to the one that you manually created in order to detect any inconsistencies


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.