Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.2.4
Name and version of the database you are using: MS SQL Server 2005
We have a table that is used for generation of IDs through legacy code (stored procedures). At the same time we have JPA entities for which we would like to use standard @TableGenerator annotation as follows:
Code:
@TableGenerator(name = "OUR_SYSID_GEN",
table = "ID_SRC",
pkColumnName = "TYPE",
valueColumnName = "SYSID",
allocationSize = 10,
pkColumnValue = "TYPE1")
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "OUR_SYSID_GEN")
@Column(name = "ID")
private Integer _id;
Unfortunately we cannot do this because it's mapped to org.hibernate.id.TableHiLoGenerator that always increments the value in the table by one, but really allocates allocationSize numbers where each number is created as:
id = lastkeyval*allocationSize + i where 0<i<allocationSize
if the table is used by this JPA generator and by legacy code it will cause id collisions. This issue is already reported in HHH-3407.
The question is how can I substitute my own generator implementation instead of TableHiLoGenerator in JBoss 4.2.X EJB3 application without compromising JPA compliance?
Is it possible to hook up custom generator implementation deployed in EAR file though configuration?
Of cause I can do something like modify the TableHiLoGenerator and repackage hibernate3.jar, but it would be the last resort.