Error when using an initial value for an entity


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

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: [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.

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:

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