Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Exception: Can't write; duplicate key in table '#sql-948_1fc'
Exception: Can't write; duplicate key in table '#sql-948_1fc' [message #1423127] Sun, 14 September 2014 00:05 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 217
Registered: July 2009
Senior Member
Hi all,
I get a lot of the following Exceptions when my applications starts:

[EL Warning]: 2014-09-14 01:49:15.005--ServerSession(8488715)--Exception
[EclipseLink-4002] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Can't write; duplicate key in table '#sql-948_1fc'
Error Code: 1022
Call: ALTER TABLE MY_TABLE ADD CONSTRAINT FK_MY_TABLE_FK_FOREIGNTAB
FOREIGN KEY (FK_FOREIGNTAB) REFERENCES MY_TABLE (ID)
Query: DataModifyQuery(sql="ALTER TABLE MY_TABLE ADD CONSTRAINT
FK_MY_TABLE_FK_FOREIGNTAB FOREIGN KEY (FK_FOREIGNTAB) REFERENCES
MY_TABLE (ID)")


The application then runs correctly, but I don't know how to eliminate
this Exception. How could I do this?

My persistence properties:

<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation"
value="create-or-extend-tables" />
<property name="eclipselink.logging.level" value="FINE" />
</properties>


Any hints are welcome...

TIA,
Ralf.
Re: Exception: Can't write; duplicate key in table '#sql-948_1fc' [message #1425667 is a reply to message #1423127] Wed, 17 September 2014 16:59 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1342
Registered: July 2009
Senior Member
The exception is a normal occurrence when running DDL on a database that already has tables and foreign keys defined, and is only logged at the warning level. You can avoid it by not using the create-or-extend DDL generation, or turn down the log level.

https://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging
Re: Exception: Can't write; duplicate key in table '#sql-948_1fc' [message #1729964 is a reply to message #1425667] Wed, 20 April 2016 14:54 Go to previous message
Vicente Rossello is currently offline Vicente RosselloFriend
Messages: 3
Registered: April 2016
Junior Member
The problem is that Mysql is very slow to throw this error, so startup performance is greatly affected by this. It would be very useful to have this alter table output to a file instead to database so we can execute only the part we want.
Previous Topic:DDL Generation: Output alter table to a file (only to file)
Next Topic:weaving errors with eclipseLink 2.6.2
Goto Forum:
  


Current Time: Sat Mar 28 15:28:09 GMT 2020

Powered by FUDForum. Page generated in 0.02085 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top