Error when using an initial value for an entity

Hi,

I try to set an initial value for a column when creating a new row.
I did it like this in psi_global->com.company.psi.entity:

public String getDoc() {
    doc = java.util.UUID.randomUUID().toString();
    return doc;
}

I can see the initial value when I click on create,
but, when trying to save the new row,
I get this error:

IllegalStateException: Datasource doesn't contain item to select: com.company.psi.entity.PsiDoc-4b837b2d-566d-423b-a18f-cd3c0da5ed39 [detached]

When I then click on logout and discard the changings, log in again, I can see, that the row has been saved in the DB.

And,
when I take out the ‘doc = java.util.UUID.randomUUID().toString();’ ,
click on create and type in the same value into the column manually and save it,
everythings works fine.

Any idea?

solved: found the error.
I changed the value injection to this:

@Id
@Column(name = "DOC_ID", nullable = false, length = 45)
protected String doc = java.util.UUID.randomUUID().toString();