-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cross Database Identity/sequence generation usingannotation
PostPosted: Thu Feb 28, 2008 1:16 pm 
Newbie

Joined: Thu Feb 28, 2008 1:01 pm
Posts: 2
Hello,

I have a requirement to build the persistence layer to work with any database i.e cross databases.

I have configured @ID for with below Generator.

Code:
@ID
@GenericGenerator(name="pid-ul", strategy="[b]native[/b]",
       parameters = {
          @Parameter(name="sequence", value="ul_seq_id")
       }
    )
@Column(name = "USER_LICENSE_ID", unique = true, nullable = false, precision = 22, scale = 0)
@GeneratedValue(generator="pid-ul")
public long getUserLicenseId() {
return this.userLicenseId;
}



I have tested above in mysql, it was working fine. when I have tested with Oracle the id value is null.

Why GenericGenerator is not using the sequence available in Oracle database to generate the next sequence value?

My understanding of the above GenericGenerator configuration is

If am using mysql database it should use the database identity generation
If am using Oracle database it shoule use the provided sequence name("ul_seq_id") provided as part of parameters.

any help in this regards will be helpful.

best wishes
srini jalagam
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 2:00 pm 
Regular
Regular

Joined: Wed Nov 17, 2004 11:49 am
Posts: 65
Location: Pittsburgh
If you want to be database agnostic, why not use a non native id generation strategy, like @TableGenerator?


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.