Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6885
  • Last Modified:

<generator class="native"/> doubt

what is the difference between

<generator class="native"/>
  and
<generator class="assigned"/>

in hibernate
0
priyapratheep
Asked:
priyapratheep
1 Solution
 
darkappleCommented:
native is  used whenever you have your underlying database handling the primary key generation. Hibernate choose itself a best way to generate id according to database it is interacting with

whenever you are confused which generator to choose, give a try with native.

use assigned whenever you have own style of generating ids. Sometimes whenever i've random data in my table and hibernate is unable to identify pattern for generating next id, i use assigned so that i can manually generate my ids and supply it  for persistence.

Remember, if you haven't chosen any generator you have supply it by yourself i.e. assigned is a default generator.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now