public void created ( final UUID createdByEntityId ) { if ( this . entityId != null ) { throw new IllegalStateException ( "This entity has already been created: entityId = " + entityId ) ; } this . entityId = UUID . randomUUID ( ) ; this . entityVersion = 1 ; this . createdByEntityId = createdByEntityId ; this . updatedByEntityId = createdByEntityId ; this . entityCreatedOn = System . currentTimeMillis ( ) ; this . entityUpdatedOn = this . entityCreatedOn ; }
Call this method when the entity is updated to increment its version and update its lastupdatedByEntityId