I found the root cause of the problem.
the following method is executed when the hibernate persist
TokenTrack object, inside
new ForeignKeys.Nullifier() method some code try to look for the token object in the DB, but it couldn't find the token, when this happen it nullify the token so this explain the error message.
Code:
protected Serializable performSaveOrReplicate(
Object entity,
EntityKey key,
EntityPersister persister,
boolean useIdentityColumn,
Object anything,
EventSource source,
boolean requiresImmediateIdAccess) {
...
new ForeignKeys.Nullifier( entity, false, useIdentityColumn, source )
.nullifyTransientReferences( values, types );
...
But why hibernate can't find the token object even it's persisted in the DB!!!!!
I tried to find the token by ID and i couldn't
Code:
Token myToken = _tokenDAO.findById(token.getTokenPK());
the TokenPK is a composit primary key that consist of three columns (integer, integer, date)
I think that the problem is related to date column, any help please advice.
BTW: I know that composite keys are bad practice and we should prefer surrogate keys, but I tried and failed to change the system analyst mentality who do this design.