I am new to JPA and databases in general. I was trying to generate entities from tables using JPA tools in Eclipse. There are a number of tables and I am trying to generate entities for all of them at the same time. The JPA tool gives me the following options for Key-generator.
I looked around on Google a bit but could not find much that addresses all the options. What do the options mean?
The JPA specification document provides answers in section 11.1.20, on pages 449 and 450:
In case you are not familiar with the Id annotation, here is a quick explanation by Vlad Mihalcea from t/his blog post:
The types of primary key generation are defined by the
GenerationType
enum:TABLE, SEQUENCE, IDENTITY, AUTO
The JPA spec gives details on those types as follows:
A well-established and recommended strategy is to chose the
SEQUENCE
strategy, if that is supported by the database management system.Note well, that strictly speaking, there is no
NONE
strategy defined in the JPA spec. The corresponding option in the select one menu, depicted in the screenshot, simply expresses that "none" of the four regular types shall be set. This seems to be a fallback to indicate you don’t have chosen your strategy for now. Still, you should pick one from the regular ones.