Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

insert data in toplink

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
When I run my program so that insert a new record in table in database and occur error: java.sql.SQLException: ORA-00001 unique constraint. I using method registerObject of UnitOfWork class. After that I check database and constraint and insert data by sql is OK. What happen. Why I insert data by sql command is OK but when run program not OK.
You can explain for me and can fix error. I using oracle 8.1.7 for windows and oracle toplink workbench 10.1.3
Thank for help me
 
ranger
Posts: 17346
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
I am not familiar with TopLink, but let me ask you this. For your Inserted record, are there relationships to other tables, like this is a Many side in a One-To-Many? Or is it a straight single table, no FK relationships insert?

So, if it is, then what this means is that it is trying to insert a record on the many side, where there is no record (Parent record) in the one side. So you can't have a child without a parent.

Mark
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kia,

This simply could be that the primary key of the object that you are trying to persist matches the primary key of an existing row. I assume you are using native sequencing? Take a look at the SQL that is generated at insert time. That should give you an indication that the sequence from which you are obtaining new primary keys has an overlap of existing primary keys.

By the way, the TopLink discussion forum (http://forums.oracle.com/forums/forum.jspa?forumID=48) has lots of answers to these, and far more complex issues. I highly recommend you peruse postings there as this forum seems primarily visited by Hibernate users. Additionally, the TopLink discussion forum is regularly visited and contributed to by both members of the TopLink product management and TopLink development teams at Oracle, and is free to post and read.

Hope that helps,

Doug
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"dgschwind",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Mark Spritzler
ranger
Posts: 17346
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

This simply could be that the primary key of the object that you are trying to persist matches the primary key of an existing row.



That too.

Mark
reply
    Bookmark Topic Watch Topic
  • New Topic