In below there is question and answer, What I need is I want comment about the a
ID: 3599066 • Letter: I
Question
In below there is question and answer, What I need is I want comment about the answer( feel free to agree or disagree with answer and explain why you agree or disagree)
Question:
Discuss some of the primary key generation strategies in JPA and when and why would you use the a certain approach.
Answer:
JPA contains four types of key generation; Auto, Identity, Sequence, and Table. Each is designed to be used for different applications and scenarios.
Auto: The system decides on one of the below strategies to use based on the specific database dialect. This may be best if the database type is unknown, although a database will be required for the system to identify which type of generation is needed.
Identity: Uses an autogenerated id unique to a specific column. This is best used when using databases that have an autoincrement primary key column like the SQL variants.
Sequence: Some databases have unique primary keys that are used to define the row by the database sequence. An example of this would be when using Oracle.
Table: An additional table is used to create a sequence.
Explanation / Answer
The answer provided are very precise, and lot of the information are missing while describing the last three key generation strategies.
You can add a pros and cons point for all the strategy, atleast the cons in strategy which will help to decide the strategy.
The Sequence strategy was not finished completely, the example was provided, but the answer mentioned of proving example.
Following are the additional points can be added to the strategy:
Identity :
1. It is not the best approach from performance point of view
2. However from data base point of view, it is very efficient since it doesn't requires any additional statement.
Sequence:
1. This strategy need additional select statement inorder to get the next value from database sequence
2. This strategy doesn't have performance impact for lot of applications.
Table :
1. This strategy was rarely useful now a days. It will induce the list by storing and updating the available value in the DB table, that put all the transaction in sequential order
2. However it will slow down the application.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.