This discussion is archived
1 Reply Latest reply: May 21, 2013 11:39 AM by cdelahun RSS

Best way to implement auto increment in JPA.

1009582 Newbie
Currently Being Moderated
What is the best way to implement auto increment in JPA so that it will support all databases such as MySQL, MSSQL Server, Oracle etc. ? Or is there any way to set auto increment strategy in common place such as persistence.xml? Please help...
  • 1. Re: Best way to implement auto increment in JPA.
    cdelahun Pro
    Currently Being Moderated
    All JPA strategies require something (like a table or sequence object) be in the database, with table sequencing being the most portable, though EclipseLink does allow custom sequence stratgies where you could use something else, such as the UUID. Sequencing is described here described here http://wiki.eclipse.org/EclipseLink/Examples/JPA/PrimaryKey with a custom UUID example shown here http://wiki.eclipse.org/EclipseLink/Examples/JPA/CustomSequencing .

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points