[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-354) @javax.persistence.SequenceGenerator defaults to 'seqhilo' strategy.

Andrew Pitt (JIRA) noreply at atlassian.com
Mon Mar 23 16:21:38 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32700#action_32700 ] 

Andrew Pitt commented on ANN-354:
---------------------------------

I agree this is not a bug, but I also agree that the solution is less than ideal.

With so much of hibernate being configurable, I'm surprised the hilo generator would be hard coded in.  Adding "allocationSize=1" to your annotations is fine if you have one or two, but a maintenance pain if you have many.

If the hilo generator is going to be forced on developers, it would be nice to at least be able to alter the allocationSize in the config, so that there's only ONE place to maintain this value.

- Andrew

> @javax.persistence.SequenceGenerator defaults to 'seqhilo' strategy.
> --------------------------------------------------------------------
>
>                 Key: ANN-354
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-354
>             Project: Hibernate Annotations
>          Issue Type: Improvement
>    Affects Versions: 3.2.0.cr1
>            Reporter: Andrey Petrov
>
> When using an oracle-style sequence to auto generate primary key values like this:
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySeq")
>     @SequenceGenerator(name="MySeq", sequenceName="ORACLE_SEQ")
>     public long getId() {
>         return id;
>     }
> then a org.hibernate.id.SequenceHiLoGenerator is always used. 
> There should be a way to configure a different generator!
> Since the hilo generator is not suitable for my application I have to use this instead:
>     @Id
>     @GeneratedValue(generator="MySeq")
>     @GenericGenerator(
>         //this is a hibernate-specific hack to force the use of a regular sequence generator
>         //otherwise a sequencehilo generator is used by default :-(((
>         name = "MySeq", strategy = "sequence", parameters = {
>             @Parameter(name = "sequence", value = "ORACLE_SEQ")
>         }
>     )
>     public long getId() {
>         return id;
>     }
> Now this works fine and while this solution can be tolerated for my app I really wish there was another way to control the default generator strategy (sequencehilo or plain sequence) without resorting to hibernate-specific org.hibernate.annotations.GenericGenerator annotations.
> Do you think a mechanism for configuring that can be added to a future hibernate annotations version?
> p.s.
> as long as i can see the seqhilo generation strategy is hardcoded in:
> org.hibernate.cfg.AnnotationBinder.java:1925:			case SEQUENCE:
> org.hibernate.cfg.AnnotationBinder.java:1926:				return "seqhilo";
> (in hibernate annotations version 3.2.0.cr1)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list