Created
May 18, 2016 11:42
-
-
Save RELATO/f4123ff59df866b25a12a0a317aaf22f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#tips: http://www.programcreek.com/java-api-examples/index.php?api=org.hibernate.annotations.Parameter | |
package com.supportmycode.model; | |
import javax.persistence.Entity; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.Id; | |
import javax.persistence.GenerationType; | |
import org.hibernate.annotations.GenericGenerator; | |
import org.hibernate.annotations.Parameter; | |
@Entity(name = "hilo") | |
public class Hilo { | |
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hilo_sequence_generator") | |
@GenericGenerator( | |
name = "hilo_sequence_generator", | |
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", | |
parameters = { | |
@Parameter(name = "sequence_name", value = "hilo_seq"), | |
@Parameter(name = "value_column", value = "next_value"), | |
@Parameter(name = "initial_value", value = "1"), | |
@Parameter(name = "increment_size", value = "1"), | |
@Parameter(name = "optimizer", value = "hilo") | |
}) | |
@Id | |
private Long id; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good tut:: https://vladmihalcea.com/2014/07/08/hibernate-identity-sequence-and-table-sequence-generator/