I have used @GeneratedValue(strategy = GenerationType.AUTO) to generate primary key id (netbeans default type - 'long'). Sometimes, I am getting the following exception:
EJB5071: Some remote or transactional roll back exception occurred
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
Duplicate entry '1473486' for key 1Error Code: 1062
I have also tried TableGenerator. But getting same exception after a while for one or two transactions.
@TableGenerator(name="test_table", table="ID_GEN", pkColumnName="ID_NAME", valueColumnName="ID_VAL", pkColumnValue="TEST_TABLE_ID", allocationSize=1)
Database: MYSQL 5.0.22
OS: Ubuntu server 6.01
App server: Sun Java System Application Server Platform Edition 9.0_01
Couldn't trace what's causing this exception as it doesn't happen all the time or for all transactions. Anyone facing this problem? any workaround?
THANKS in advance.
[Message sent by forum member 'server_user' (server_user)]
http://forums.java.net/jive/thread.jspa?messageID=233193