KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Q1. : What is the difference between applying sequence Id in a database using A. CREATE TABLE Person ( id long NOT NULL AUTO_INCREMENT ... PRIMARY KEY (id) ) versus B. @Entity public class Person { @Id @TableGenerator(name="TABLE_GEN", table="SEQUENCE_TABLE", pkColumnName="SEQ_NAME", valueColumnName="SEQ_COUNT", pkColumnValue="PERSON_SEQ") @GeneratedValue(strategy=GenerationType.TABLE, generator="TABLE_GEN") private long id; ... } My system is highly concurrent . Since my DB is a Microsoft SQL server, I do not think it supports @SequenceGenerator , so I have to stay with @TableGenerator which is prone to concurrency issues. Q2. This link here ( http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Advanced_Sequencing ) suggests that B might suffer from concurrency issues, but I do not understand the proposed solution. I would greatly appreciate it if someone could explain to me how to avoid concurrency issues with B . Here is a snippet of their solution: If a large sequence pre-allocation size is used this becomes less of an issue, because the sequence table is rarely accessed. Q2.1 : How much allocation size are we talking about here? Should I do allocationSize=10 or allocationSize=100 ? Some JPA providers use a separate (non-JTA) connection to allocate the sequence ids in, avoiding or limiting this issue. In this case, if you use a JTA data-source connection, it is important to also include a non-JTA data-source connection in your persistence.xml. Q2.2</stron
Tags (comma-separated)
Save Edits
Cancel