java - Application- vs database- generated keys -


i'm taking spring batch example illustrate question since thought when looking @ spring batch docs.

if @ this section, can read:

however, not database generated keys, rather generated separate sequences. necessary because after inserting 1 of domain objects database, key given needs set on actual object can uniquely identified in java. newer database drivers (jdbc 3.0 , up) support feature database generated keys, rather requiring it, sequences used.

until now, proceeded follows:

  1. create entity (no identifier assigned yet - e.g. key null)
  2. use repository persist entity. database generates unique identifier entity. identifier can accessed using jdbc api.
  3. set identifier created entity

what pros , cons of using method versus application-generated keys method?

thanks, mickael


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -