Posted by felipegaucho
on September 7, 2009 at 6:12 AM PDT
During my studies I found some details about the JPA that suggested me I should never use long as ID type for my JPA Entities.
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.