• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

ORA-00001: unique constraint exception

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI ..

I am getting the following exception when i try to insert a new row in a table:--
===========================================================================

2007-12-11 12:47:27,898 WARN

[net.sf.hibernate.util.JDBCExceptionReporter] SQL Error: 1, SQLState:

23000
2007-12-11 12:47:27,898 ERROR

[net.sf.hibernate.util.JDBCExceptionReporter] ORA-00001: unique

constraint (UST.UK_PROJECT_REFERENCE) violated

2007-12-11 12:47:27,898 WARN

[net.sf.hibernate.util.JDBCExceptionReporter] SQL Error: 1, SQLState:

23000
2007-12-11 12:47:27,898 ERROR

[net.sf.hibernate.util.JDBCExceptionReporter] ORA-00001: unique

constraint (UST.UK_PROJECT_REFERENCE) violated

2007-12-11 12:47:27,898 WARN

[net.sf.hibernate.util.JDBCExceptionReporter] SQL Error: 1, SQLState:

23000
2007-12-11 12:47:27,898 ERROR

[net.sf.hibernate.util.JDBCExceptionReporter] ORA-00001: unique

constraint (UST.UK_PROJECT_REFERENCE) violated

2007-12-11 12:47:27,898 WARN

[net.sf.hibernate.util.JDBCExceptionReporter] SQL Error: 1, SQLState:

23000
2007-12-11 12:47:27,898 ERROR

[net.sf.hibernate.util.JDBCExceptionReporter] ORA-00001: unique

constraint (UST.UK_PROJECT_REFERENCE) violated

2007-12-11 12:47:27,898 ERROR [net.sf.hibernate.impl.SessionImpl]

Could not synchronize database state with session
2007-12-11 12:47:27,898 INFO [STDOUT]

net.sf.hibernate.exception.ConstraintViolationException: Could not

execute JDBC batch update
at

net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConver

ter.java:73)
at

net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionH

elper.java:29)
at net.sf.hibernate.impl.BatcherImpl.convert(BatcherImpl.java:328)
at

net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:135)
at

net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:6

1)
at

net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:5

8)
at

net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.j

ava:111)
at

net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav

a:454)
at

net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav

a:436)
at

net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.j

ava:37)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at

net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at

net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.jav

a:52)
at

com.pms.ust.model.USTModelManager.createDossier(USTModelManager.java:

642)
at

com.pms.desyre.v2.EmptySpecialUpgradeSubmitter.submit(EmptySpecialUpg

radeSubmitter.java:56)
at com.jnc.novell.pagewizard.Wizard.finishPage(Wizard.java:600)
at com.jnc.novell.pagewizard.Wizard.perform(Wizard.java:456)
at

com.jnc.novell.pagewizard.Wizard.processWizardRequest(Wizard.java:718

)
at

com.jnc.novell.pagewizard.WizardComponent.ebi_processRequest(WizardCo

mponent.java:75)
at

com.jnc.migration.AbstractComponentWrapper.processRequest(AbstractCom

ponentWrapper.java:118)
at

com.novell.afw.component.core.EboComponentContainer.performInteractio

n(EboComponentContainer.java:140)
at

com.novell.afw.component.core.EboComponentContainer.performBlockingIn

teraction(EboComponentContainer.java:166)
at

com.novell.afw.portal.proxy.EboPortletContainerProxy.performBlockingI

nteraction(EboPortletContainerProxy.java:197)
at

com.novell.afw.portal.aggregation.EboPortletProxyHelper.callPortletAc

tionRequest(EboPortletProxyHelper.java:480)
at

com.novell.afw.portal.aggregation.EboPortalAggregationControllerImpl.

checkAndHandleActionURLType(EboPortalAggregationControllerImpl.java:1

987)
at

com.novell.afw.portal.aggregation.EboPortalAggregationControllerImpl.

initiateRendering(EboPortalAggregationControllerImpl.java:1261)
at

com.novell.afw.portal.aggregation.EboPortalAggregationControllerImpl.

renderPortalPIDResponse(EboPortalAggregationControllerImpl.java:883)
at

com.novell.afw.portal.aggregation.EboPortalAggregationControllerImpl.

renderPortalPIDResponse(EboPortalAggregationControllerImpl.java:832)
at

com.jnc.novell.rendering.EboDocumentRendererServlet.processContentReq

uest(EboDocumentRendererServlet.java:678)
at

com.jnc.novell.rendering.EboDocumentRendererServlet.service(EboDocume

ntRendererServlet.java:453)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:252)
at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:173)
at

com.pms.ost.security.OSTDossierSecurityFilter.doFilter(OSTDossierSecu

rityFilter.java:154)
at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:202)
at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:173)
at

com.pms.ust.security.USTDossierSecurityFilter.doFilter(USTDossierSecu

rityFilter.java:241)
at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:202)
at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:173)
at

com.jnc.novell.director.filter.UserSessionMonitorFilter.doFilter(User

SessionMonitorFilter.java:73)
at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:202)
at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:173)
at

org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi

lter.java:81)
at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:202)
at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:173)
at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

alve.java:213)
at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

alve.java:178)
at

org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc

ipalValve.java:39)
at

org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit

yAssociationValve.java:153)
at

org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv

e.java:59)
at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

ava:126)
at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

ava:105)
at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

ve.java:107)
at

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

a:148)
at

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

:856)
at

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

ssConnection(Http11Protocol.java:744)
at

org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo

int.java:527)
at

org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor

kerThread.java:112)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique

constraint (UST.UK_PROJECT_REFERENCE) violated

at

oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseEr

ror.java:367)
at

oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePrepare

dStatement.java:8739)
at

org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(Wrapped

Statement.java:701)
at

net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.

java:54)
at

net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)
... 57 more

===========================================================================


Could any one help me what would be the problem...
Please suggest me as early as possible, as it is an urgent issue.

Thanks And Regards,
Chandrakanth
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you setting your id field in your app and trying to get Hibernate to insert the record, but there is already a record in your database with that id.

Can you post you xml mapping for this resource, especially the <id> and also how you are generating the id.

Thanks

Mark
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No...i want to create a new order ...which inserts a new row in the table.
But it is not able to insert due to this unique constraint problem.
even if i disable the constraint for that particular coloumn , the error is same.
i will add the hbm file..
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried to post hbm file contents but javaranch site is not allowing me to update the file contents..
how do i do this?
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping auto-import="true" package="com.pms.ust.model"> <!-- Class mapping definition --> <class name="USTDossier" table="UST_DOSSIER" mutable="true" dynamic-insert="true" dynamic-update="true" > <id name="id" column="OID" type="long" unsaved-value="null" > <generator class="sequence"> <param name="sequence">UST_DOSSIER_SEQ</param> </generator> </id> <version name="version" column="DB_VERSION" unsaved-value="negative" /> <!-- Regular plain mapped columns --> <property name="creationUser" column="CREATION_USER" type="string" not-null="true" /> <property name="creationDate" column="CREATION_DATE" type="date" update="false" /> <property name="projectReference" column="PROJECT_REFERENCE" type="string" update="false" unique="true" /> <many-to-one name="dossierStatus" column="STATUS" class="USTDossierStatus" not-null="true" /> <property name="SSDDescription" column="SSD_DESCRIPTION" type="string" /> <property name="SSDPreferredResponseDate" column="SSD_DELIVERY_DATE" type="date" /> <property name="USTDescription" column="UST_DESCRIPTION" type="string" /> <property name="requestType" column="REQUEST_TYPE" type="string" />
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To post code, there is a CODE tag below the Add Reply button. So you open your file in some text editor, and copy and paste it into a post. Unfortunately, I cannot read what you posted because it has no indentation and all meshed into one paragraph.

So explain what you mean by you wanting to re-order? Based on what, I hope not your ID.

Mark
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You said you disabled the constraint, but that still looks to me like a database constraint.
Could you check constraint UK_PROJECT_REFERENCE in your database
to make sure that is the one you in fact disabled?
[ December 15, 2007: Message edited by: Bougnon Kipre ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, here is what I think is happening.

You have



What is the next val from the UST_DOSSIER_SEQ, is it a value that already has a record in the database with that PK id? Did you reset your sequence to 0 because you wanted it re-ordered, but you already have records in your database with those PK values?

Mark
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bougnon Kipre,

I have disabled the constraint for UK_PROJECT_REFERENCE.
I checked twice to confirm .
But still the problem is same.
I am surprising.

Thanks and Regards,
Chandrakanth
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mark Spritzler,

Actually i changed the sequence and still the problem remains same.
Before the row is going to insert in UST_DOSSIER table, a TRIGGER will create the UST_PROJECTREFERENCE number and isert in to the coloumn.


Thanks and Regards,
Chandrakanth
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, sorry, I kept reading and thinnking the unique constrain violation was on the PK, which is generated from the sequence.

But what you are getting is a different violation, from a different field. Which will not be affected by the sequence. I apologize for not seeing that clearly.

OK, so the column that is in question here is being filled in by the trigger. So the problem is in your trigger, and has absolutely nothing to do with ORM or Hibernate.

Mark
 
chandrakanth boga
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mark Spritzler,

Nevermind.
Even i thought the problem could be trigger.
But since many months it did not given any problem.
Just recently the problem has arised.
And we dont know why??
Here is hte trigget which fills the coloumn:--

Do you find any problem in this trigger.

Cheers

[ Edited to use code tags - Paul Sturrock ]
[ December 18, 2007: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chandrakanth boga:
But since many months it did not given any problem.
Just recently the problem has arised.



Nothing surprising it happens in real life.
Please format your trigger code using '[code]' tag. Thanks.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing pops out from reading it.

Just have this question.

What is this for?
SUBSTR(TO_CHAR(SYSDATE, 'YYYYMM'),3)

To me it looks like you are trying to get the current date in YYMM format. The last two digits of the Year then the two digits of the Month. So why use YYYYMM and Substring combined, can't you just use TO_CHAR(SYSDATE, 'YYMM') ?

So this trigger for this field, what is its purpose, do you really need it? What value is it creating that your application needs? Waht is the result it is returning that is a value that is already in the database? That is what you need to look for.

Good Luck

Mark
reply
    Bookmark Topic Watch Topic
  • New Topic