Hallo,
ich habe folgendes mapping:
Code:
@Id
@Column(name = "ID", unique = true, nullable = false, precision = 28, scale = 0)
@GeneratedValue(generator = "generator")
@GenericGenerator(name = "generator", strategy = "sequence-identity",
parameters = @Parameter(name = "sequence", value = "BS_SEQ_KL_ID"))
public long getId() {
return this.id;
}
public void setId(final long id) {
this.id = id;
}
Es funktioniert, bringt mir aber eine Warnung:
Code:
WARN org.hibernate.orm.deprecation - HHH90000014: Found use of deprecated [org.hibernate.id.SequenceIdentityGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead. See Hibernate Domain Model Mapping Guide for details.
wenn ich es daraufhin der Doku entsprechend umbaue:
Code:
@Id
@Column(name = "ID", unique = true, nullable = false, precision = 28, scale = 0)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BS_SEQ_KL_ID")
@SequenceGenerator(name = "BS_SEQ_KL_ID", sequenceName = "BS_SEQ_KL_ID")
public long getId() {
return this.id;
}
public void setId(final long id) {
this.id = id;
}
Erhalte ich bei einem Insert einen Fehler:
Code:
org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session
Ich denke die Ursache ist, dass es die erzeugte ID bereits existiert. Was mache ich hier falsch?
Viele Grüße