Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ID generation for more than 50 objects created in one transaction #194

Open
szpak opened this issue May 28, 2013 · 0 comments
Assignees
Labels
Milestone

Comments

@szpak
Copy link

szpak commented May 28, 2013

@Entity
public class Image {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "image_sequence")
    @SequenceGenerator(name = "image_sequence", sequenceName = "image_sequence")
    private Long id;

    @Column
    String name;

   (...)
}

Creating more than 50 images in one transaction (on freshly initialized database) results in:

java.sql.SQLException: ERROR: duplicate key value violates unique constraint "image_pkey"
  Detail: Key (id)=(2) already exists. Query: INSERT INTO Image
(id, name)
VALUES
    (?, ?) Parameters: [2, foo]

Batoo took 50 numbers from sequence and had problem when used all of them? It works fine with allocationSize set to 1. BatooJPA 2.0.1.0-RTM, PopstgreSQL 9.2.

Sample test code snippet (in Spock with SpringData):

(...)
    @Transactional
    def "should allow to insert over 50 images in one transaction"() {
        setup:
            for (i in 0..50) {
                imageRepository.save(new Image("foo"));
            }
        expect:
            imageRepository.count() == 51
    }
@asimarslan asimarslan added the bug label Oct 26, 2014
@asimarslan asimarslan added this to the 2.0.1.3 milestone Oct 26, 2014
@asimarslan asimarslan self-assigned this Oct 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants