Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert data in toplink

 
Kia Phia Ben
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
Doug Gschwind
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65337
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic