Results 1 to 3 of 3

Thread: Duplicate entry for key

Threaded View

  1. #1
    Join Date
    Jul 2009
    Posts
    18

    Default Duplicate entry for key

    Hello,

    When i save this class.

    Code:
    @Entity
    @RooEntity
    @RooJavaBean
    @RooToString
    public class Productgroup {
    
        @NotNull
        @Size(max = 30)
        private String name;
    
        @OneToMany(cascade = CascadeType.ALL)
        private Set<Prefix> prefixes = new HashSet<Prefix>();
    
        @OneToMany(cascade = CascadeType.ALL)
        private Set<Postfix> postfixes = new HashSet<Postfix>();
    }

    I get a the following error.

    Caused by: java.sql.BatchUpdateException: Duplicate entry '1' for key 2
    at com.mysql.jdbc.PreparedStatement.executeBatchSeria lly(PreparedStatement.java:1666)
    at com.mysql.jdbc.PreparedStatement.executeBatch(Prep aredStatement.java:1082)
    at org.apache.commons.dbcp.DelegatingStatement.execut eBatch(DelegatingStatement.java:297)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( BatchingBatcher.java:48)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:246)
    ... 107 more

    This only occurs when i use hibernate with mysql not when i use openjpa with mysql. To reproduce execute the attached script, run wepapp, create some prefixes and postfixes, create two productgroups that have a relation to the same prefix or postfix.

    Kind regards,

    Ronald Vermeire
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •