first of all, I don't speak english correctly, so, sorry for the mistakes.
I having a problem, when I try to create a entity (with id NULL, then the database will assign it) and the creation fails, the entity is left with the generated ID. I need that the id remain null if the creation fails, because in my service, I check if the entity passed to "save" method, contains ID or not, to make an update or an create.
I can set the ID in null if the creation fails, but when I making more complex transactions, is hard to change manually every ID in every entity, and some times, some objects are fetched from the database and others not.
I hope that I have explained correctly... Thanks.
PD: This is the field ID in the entity...
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
PD2: I using Spring framework by the way.
EDIT: I using PostgreSQL, and try every generation posible.