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:
- create entity (no identifier assigned yet - e.g. key null)
- use repository persist entity. database generates unique identifier entity. identifier can accessed using jdbc api.
- set identifier created entity
what pros , cons of using method versus application-generated keys method?
thanks, mickael
Comments
Post a Comment