-->
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.  [ 4 posts ] 
Author Message
 Post subject: org.hibernate.exception.ConstraintViolationException ??
PostPosted: Fri Jan 13, 2006 10:44 am 
Beginner
Beginner

Joined: Fri Jan 13, 2006 8:07 am
Posts: 29
I get following error :

Hibernate: insert into EVENTS (EVENT_DATE, TITLE) values (?, ?)
org.hibernate.exception.ConstraintViolationException: could not insert: [events.Event]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1986)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2405)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:544)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:533)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:529)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292)
at $Proxy0.save(Unknown Source)
at events.EventManager.createAndStoreEvent(Unknown Source)
at events.EventManager.main(Unknown Source)
Caused by: java.sql.SQLException: ORA-01400: cannot insert NULL into ("DAWEB_USER"."EVENTS"."EVENT_ID")

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1976)
... 22 more
Exception in thread "main"

Is that something to do with the generator class ? Please help me out ..

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 10:54 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:20 am
Posts: 74
yes, it's attempting to insert a NULL value into a table that has NOT NULL set for the column it's trying to insert into.
As your generator seems to not be working you're likely seeing a side effect of that (the value would be NULL until after the generator returns a real value to use instead).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 11:45 am 
Beginner
Beginner

Joined: Fri Jan 13, 2006 8:07 am
Posts: 29
so, what should I do for correcting this ? am not clear



Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 6:28 pm 
Newbie

Joined: Thu Jan 24, 2008 5:52 pm
Posts: 1
Hi:
Check the generator class in your Event.hbm.xml that is suitable to your needs. You should read http://www.hibernate.org/hib_docs/refer ... pping.html in section 5.1.4.1. Generator. As I see in your stack trace you are using Oracle as DBMS.

For example for my non-clustered DB2 database
In my Event.hbm.xml:
Code:
        <id name="id" column="EVENT_ID">
            <generator class="sequence">
                <param name="sequence">event_sequence</param>
            </generator>
        </id>


And create the database sequence object:
Code:
db2 =>create sequence event_sequence start with 1 increment by 1



Hope Its usefull


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