Long or int to declare JPA numeric primary keys?
I have just two arguments to avoid using long as type of the primary keys of JPA Entities:
- Integers IDs allow tables with ~2 billion records. Yes, you read well: max(Integer) = 2,147,483,647
- the JPA pagination methods only accepts Integers Query setFirstResult(int startPosition) an Query setMaxResults(int maxResult)
Summary:only adopt data types long for your tables primary keys if your tables will have ore than 2 billion records or if you are not planning to use the default pagination features of JPA.



