-->
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.  [ 6 posts ] 
Author Message
 Post subject: native generator error
PostPosted: Tue Dec 16, 2003 1:49 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi all,

I have some records in a table, added by Hibernate, using native generator. The last aloocated id is, say, 100.

If I go and insert by hand a new record with id 101, when Hibernate tries to insert a new record it gives

SQL Error: -803, SQLState: 23505
12:44:23,135 ERROR JDBCExceptionReporter:46 - [IBM][CLI Driver][DB2/SUN] SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" constrains table "DB2INST1.USERLOGININFO" from having duplicate rows for those columns. SQLSTATE=23505

It seems like Hibernate could not see the externally added record and it tries to overwrite the 101 id ??

I am using DB2 7

Please help.

TIA,
--steve p.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 3:15 pm 
Regular
Regular

Joined: Tue Sep 02, 2003 5:09 pm
Posts: 81
Location: Whitefish Montana
Did you specify the 101 like: insert into myfile (id, desc,...) values(101, 'x',...)? DB2 stores the next value with the table and it won't be incremented unless you use insert into myfile (id, desc,...) values(default, 'x',...)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 3:17 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
dmmorris wrote:
Did you specify the 101 like: insert into myfile (id, desc,...) values(101, 'x',...)? DB2 stores the next value with the table and it won't be incremented unless you use insert into myfile (id, desc,...) values(default, 'x',...)


thx for the answer.

I am actually using DB2 Control Center to manually input data. It autogenerates the SQL stuff.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 3:20 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
dia100 wrote:
dmmorris wrote:
Did you specify the 101 like: insert into myfile (id, desc,...) values(101, 'x',...)? DB2 stores the next value with the table and it won't be incremented unless you use insert into myfile (id, desc,...) values(default, 'x',...)


thx for the answer.

I am actually using DB2 Control Center to manually input data. It autogenerates the SQL stuff.


the sql generated from Command Center:

INSERT INTO
DB2INST1.USERLOGININFO
(
ID,
USER_NAME,
LOGIN_DATE,
LOGIN_TIME,
WORKSTATION,
LOGOFF_DATE,
LOGOFF_TIME,
CURR_LOGGED
)
VALUES
(
86,
'aaa',
'2003-12-16',
'14:19:56',
'2323',
'2003-12-16',
'14:20:00',
2
)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 12:43 am 
Regular
Regular

Joined: Tue Sep 02, 2003 5:09 pm
Posts: 81
Location: Whitefish Montana
Try running something like:

Code:
INSERT INTO
DB2INST1.USERLOGININFO
(ID, USER_NAME, LOGIN_DATE, LOGIN_TIME, WORKSTATION, LOGOFF_DATE, LOGOFF_TIME, CURR_LOGGED)
VALUES (default, 'aaa', '2003-12-16', '14:19:56', '2323', '2003-12-16', '14:20:00', 2)


If this works and you have support, I would report it to IBM. I think this is common with database tools. I ran into the same problem earlier this year with an integration broker inserting records into SQL Server tables.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 10:13 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
dmmorris wrote:
Try running something like:

Code:
INSERT INTO
DB2INST1.USERLOGININFO
(ID, USER_NAME, LOGIN_DATE, LOGIN_TIME, WORKSTATION, LOGOFF_DATE, LOGOFF_TIME, CURR_LOGGED)
VALUES (default, 'aaa', '2003-12-16', '14:19:56', '2323', '2003-12-16', '14:20:00', 2)


If this works and you have support, I would report it to IBM. I think this is common with database tools. I ran into the same problem earlier this year with an integration broker inserting records into SQL Server tables.[/code]


thx! it works!


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