-->
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.  [ 5 posts ] 
Author Message
 Post subject: New SequenceStyleGenerator with JPA/Hibernate Annotations
PostPosted: Wed Apr 11, 2007 12:00 pm 
Newbie

Joined: Thu Oct 13, 2005 8:51 pm
Posts: 9
Hibernate version: 3.2.3

Sorry if this has been addressed somewhere, but neither google nor this forum search turned up results for SequenceStyleGenerator.

I'm using Hibernate latest via JPA. I've read the wiki post on the new generators, as well as the documentation with the 3.2.3 dist.

I'm currently using @GeneratedValue w/o parameters for my id columns. I see in the annotations documentation (http://www.hibernate.org/hib_docs/annot ... identifier) parameters can configure this. But it isn't clear to me how to set this up for the new strategies. I'll definitely be tinkering with this and may figure it out. But maybe getting this in the forum will help others and avoid this question coming up.

Thanks,

Stu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 12:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi,
You cna always use the @GenericGenerator to use the new Hibernate generation strategy.

Will they be the default generators? I will discuss that with Steve

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 12:58 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
package-info.java:

Code:
@GenericGenerator(
    name = "wikiSequenceGenerator",
    strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
    parameters = {
        @Parameter(name = "sequence_name", value = "WIKI_SEQUENCE"),
        @Parameter(name = "initial_value", value = "1000"),
        @Parameter(name = "increment_size", value = "1")
    }
)

package org.jboss.seam.wiki.core.model;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;


Entity:

Code:
@Entity
@Table(name = "USERS")
public class User implements Serializable {

    @Id
    @GeneratedValue(generator = "wikiSequenceGenerator")
    @Column(name = "USER_ID")
    private Long id = null;

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: SequenceGenerator
PostPosted: Fri Apr 27, 2007 1:57 pm 
Newbie

Joined: Thu Oct 13, 2005 8:51 pm
Posts: 9
christian wrote:
package-info.java:

Code:
@GenericGenerator(
    name = "wikiSequenceGenerator",
    strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
    parameters = {
        @Parameter(name = "sequence_name", value = "WIKI_SEQUENCE"),
        @Parameter(name = "initial_value", value = "1000"),
        @Parameter(name = "increment_size", value = "1")
    }
)


Thanks you two. Christian I noticed you'd updated the wiki to use this shortly after posting that (will remember to follow up for others' benefit next time :-). Once again, the wiki's a great source of examples...

Stu


Top
 Profile  
 
 Post subject: Re: New SequenceStyleGenerator with JPA/Hibernate Annotations
PostPosted: Wed Aug 20, 2014 10:28 am 
Newbie

Joined: Fri Aug 08, 2014 1:54 pm
Posts: 1
Hi....how can i configure the SequenceStyleGenerator as a Application level generators?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.