1

I always see examples of people using long for mapping IDs (PKs) on hibernate. Is there an advantage when making queries? Is there any advantage other then you can store bigger values? Why use long instead of int?

2 Answers2

0

Only real adventage for long over int is bigger range. When used as primary key, you will be able to store more rows. For some system it makes a difference.

If you are sure that you do not need that many rows, feel free to use int or even smaller number type!

Bartosz Bilicki
  • 12,599
  • 13
  • 71
  • 113
0
  • It is recommended practice.
  • When record grows, automatically id also grows. Sometimes, autoincrement flag will be set to increase the value everytime.
kavita
  • 417
  • 4
  • 8