Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Hibernate Basics Persisting Data with Hibernate Updating and Deleting Entities

Contact ID Does Not Increment By 1

For some reason, the primary id does not increment by 1 but by 32. I know I used the exact same code from the video.

The code below solved the problem, but I want to know why I'm having this problem.

    @GenericGenerator(name="increment" , strategy="increment")
    @GeneratedValue(generator="increment")
    private int id;

6 Answers

Try this : @GeneratedValue(strategy = GenerationType.TABLE)

This works

Hey Jeff, did you mark your int with the annotation @Id? The only two annotations should look something like this.

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

Yes, I did mark it with "@Id"

Hey Jeff, it might be a moot point, but can you paste all of your code and XML configuration file, I'll take a look at it, and see what I can find.

I have the same problem. Here is my code: https://github.com/Sameperson/contactmgr

Here how ids look http://i.imgur.com/Ed47Q4c.png

Alright, nice to see that I'm not the only one facing this problem

i too have the same problem :(