Home Spring GeneratedValue annotation usage
Reply: 1

Spring GeneratedValue annotation usage

webpersistence
1#
webpersistence Published in 2017-12-06 14:15:59Z

Let's say that I have a Car entity:

@Entity 
public class Car {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private Integer id;

How does spring know what value to autoincrement when I add a new object to the database?

Adnin
2#
Adnin Reply to 2017-12-06 14:20:09Z

There is good explanation of primary keys generation strategies: https://www.thoughts-on-java.org/jpa-generate-primary-keys/

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.352981 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO