Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with JPQL in Update statament (JPA)

843830Aug 19 2009 — edited Aug 27 2010
Hello,

I have one problem here. I wonder if some one could help me?

so, I need to update my entire table using JPA, I want to pass all data of one column to other column.
I im trying this:
em.createQuery("UPDATE Cole AS c SET c.coleAnt = c.coleAtu, c.forneAnt = c.forneAtu").executeUpdate();
but in some moment I got a exception like this:

*Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException*
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'PRIMARY'
Error Code: 1062
Call: INSERT INTO TL_coleta (idColeta, coleta_ant, fornecedor_ant) SELECT t0.idColeta, t0.coleta_atu, t1.idfornecedor FROM coleta t0, coleta t2, fornecedor t1 WHERE (t1.idfornecedor = t2.fornecedor_atu)
Query: UpdateAllQuery()

how Can I soulve this ???

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2010
Added on Aug 19 2009
6 comments
787 views