These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to substitute custom Id generator for @TableGenerator
PostPosted: Tue Mar 24, 2009 2:16 pm 
Newbie

Joined: Tue Mar 24, 2009 1:25 pm
Posts: 2
Location: Toronto
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.