I'm using MS SQL Server + Hibernate (JPA, more precisely, with EntityManager) and i faced with the problem: I need to store entity into appropriate table in my DB; this table has uniqueidentifier
as primary key; and storing entity already has UUID (it's primary key), with witch it should be inserted into the DB.
Problem is that when i try to merge
my entity, hibernate do some magic and store my entity with another UUID value. So, when I fetch this entity from db and take a look on it ID, I see inappropriate value.
So, I want to tell hibernate not to do that (or, maybe, there is another solution?).
My entity class:
public class Entity extends BaseEntity {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id_column")
private UUID uuId;
// other fields, getters, setters
}
Also, I have one more 'annoyance': my IDE and my DB browser shows me another ID in that column. I mean, when I stop my app in the debug mode and look at the id of an entity, I see different value from a value in the database.
Thanks in advance!