duplicate « Key « JPA Q&A





1. @SQLInsert and ON DUPLICATE KEY...    forum.hibernate.org

2. Hibernate 3.5.0-CR-2 causes duplicate primary keys    forum.hibernate.org

Hi, I just updated our builds to use the newly released 3.5.0-CR-2 release and am finding that I get duplicate primary key errors in the database all the time causing rollbacks. Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "rest_request_pkey" at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1608) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1343) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:194) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:304) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ...

3. Duplicate Key & AssertionFailure    forum.hibernate.org

After a duplicate key error java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Vio lation of UNIQUE KEY constraint 'IX_PERSON2'. Cannot insert duplicate key in obj ect 'PERSON2'. Which is correct (I really wanted to get this error) I have this error, on the app-server console: GRAVE: An AssertionFailure occured - this may indicate a bug in Hibernate net.sf.hibernate.AssertionFailure: null identifier at net.sf.hibernate.engine.Key.(Key.java:20) at ...

5. duplicate key problem    forum.hibernate.org

Newbie Joined: Fri Nov 14, 2003 3:51 pm Posts: 4 The brief info: I'm getting a net.sf.hibernate.JDBCException: Could not execute JDBC batch update ... Caused by: java.sql.SQLException: ERROR: Cannot insert a duplicate key into unique index multiple_choice_grading_pkey The table where the duplicate key error is happening is for a mapped primitive array (of ints). A similar thing is happening elsewhere for ...

6. Checking for duplicate keys.    forum.hibernate.org

Hi am using Hibernate 2.1.x but I take it this is a genarl question... Whats the best way to detect duplicate entries in a database? Bassically I have a user table... And I would like to insert the user only if he doesnt exist... The 2 options I see are... 1- Save, which will cause an insert and if it's a ...

7. BatchUpdateException Duplicate key    forum.hibernate.org

Hibernate version: 2.1.8 Hi. I take the following exception Exception: 18-01-2006 22:57:51 DEBUG [JDBCExceptionReporter.logExceptions:49] Could not execute JDBC batch update java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '541161475169' for key 1" at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1540) at com.mchange.v2.sql.filter.FilterPreparedStatement.executeBatch(FilterPreparedStatement.java:260) at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54) at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261) at com.mjoy.dcmbase.persistence.PersistenceManager.save(PersistenceManager.java:217) at com.mjoy.wapdcm.persistence.PersistenceLayer.guardarUsuario(PersistenceLayer.java:209) at com.mjoy.wapdcm.handler.BussinesLogic.saveOrUpdateUser(BussinesLogic.java:141) at com.mjoy.wapdcm.actions.ConfirmacionAction.performAction(ConfirmacionAction.java:111) at com.mjoy.wapdcm.actions.AbstractAction.execute(AbstractAction.java:54) at ...

8. Duplicate foreign keys    forum.hibernate.org

Hi, I'm facing a problem where 2 identical foreign keys (for the same column and table) are created by hbm2ddl task as a result of a few many-to-many relations. I narrowed this down to 2 classes: Member and Group. Group extends Member. Member contains a set of parent groups and Group contains a set of child groups. Here's the code: // ...

9. Problem in accessing duplicate primary key    forum.hibernate.org

Currently we are using oracle database which is not normalize. e.g. We have a table Position which have these columns 1) Id 2) Desc Example of record in this table is ID DESC P Partner1 A Associate L Paralegal P Partner P Partner Id is declared as primary key in POJO I tried the following code Query query=getSession().createQuery("from "+type+" t where ...





10. Problem in accessing duplicate primary key    forum.hibernate.org

Currently we are using oracle database which is not normalize. e.g. We have a table Position which have these columns 1) Id 2) Desc Example of record in this table is ID DESC P Partner1 A Associate L Paralegal P Partner P Partner Id is declared as primary key in POJO I tried the following code Query query=getSession().createQuery("from "+type+" t where ...

11. Duplicate PK ?    forum.hibernate.org

Newbie Joined: Mon Jul 09, 2007 9:32 am Posts: 17 I have a class Money which has two child classes: Cash, Check. Code: Cash client2usCash = (Cash) c.getBondPaymentMap().get("client2usCash"); this.getHibernateTemplate().save(client2usCash); ...

12. Ignoring duplicate keys?    forum.hibernate.org

Can anyone please point me in the right direction on how to skip existing database rows when doing session.save() without having check for existing records first? I am using the following code: pointLogs has many (~10000) values and may contain duplicates of existing records. Code: try { tx = session.beginTransaction(); ...

13. Duplicate key issue..    forum.hibernate.org