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)

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

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"

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

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.

Jani Eronen
Jani Eronen
5,767 Points

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

Arun Kumar
Arun Kumar
3,750 Points

i too have the same problem :(