Auto zoom in sleep using oracle

I am new to sleep mode and want to insert the primary number into my table for unique identification. I use Oracle as my database, so I need to create a sequence in oracle to get the auto increment generation number?

I use the code below, but it does not work. I have not created any sequences yet.

 @Id
 @Column(name = "id" )
 @GeneratedValue ( strategy = GenerationType.TABLE)

I used AUTO, SEQUENCEand IDENTITY, but nothing works for me.

+4
source share
3 answers

this is one way to use an Oracle sequence in a transformed JPA entity:

@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_NAME")
@SequenceGenerator(name = "SEQUENCE_NAME", sequenceName = "SEQUENCE_NAME", allocationSize = 1, initialValue = 1)

, persist() , .

+8

@GeneratedValue(strategy=GenerationType.AUTO)

@Id
@Column(name = "id" )
@GeneratedValue(strategy=GenerationType.AUTO)
+1

GenerationType.TABLE ID .

strategy=GenerationType.TABLE, , .

,

@GeneratedValue(strategy=GenerationType.TABLE, generator="course")
@TableGenerator(
    name="course",
    table="GENERATOR_TABLE",
    pkColumnName = "key",
    valueColumnName = "next",
    pkColumnValue="course",
    allocationSize=30
)

GenerationType.AUTO, , .

 @Id
 @Column(name = "id" )
 @GeneratedValue (strategy = GenerationType.AUTO)

, hibernate.cfg.xml.

0

Source: https://habr.com/ru/post/1530974/


All Articles