Malinda
Malinda

Reputation: 584

How can convert hibernate genarator="sequence" with increment parameter to JPA

I have following hibernate based XML properties.What i need is to convert following to JPA Annotations

  <id column="PARTNER_PROPERTY_ID" name="id" unsaved-value="0">
      <generator class="sequence">
          <param name="sequence">CRICKET_TEST_SEQ</param>
          <param name="parameters">INCREMENT BY 1 START WITH 200</param>
      </generator>
  </id>

can anyone help me to convert this code phrase to JPA annotation

Upvotes: 0

Views: 310

Answers (1)

Basharat Ali
Basharat Ali

Reputation: 1209

As i understand this property is used to generate the sequence that can also done by this annotations.

@Id
@SequenceGenerator(name="att_id", sequenceName="attendee_setup_id_seq", initialValue = 1, allocationSize = 1)

@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="att_id")

@Column(name="PARTNER_PROPERTY_ID")
private int PARTNER_PROPERTY_ID; 

Upvotes: 1

Related Questions