Code example for TransientObjectException

0
		EntityEntry entry = source.getPersistenceContext().getEntry(entity);
		if (entry==null) {
			final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
			final Serializable id = persister.getIdentifier( entity, source );
			if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
				throw new TransientObjectException(
						"cannot lock an unsaved transient instance: " + 
						persister.getEntityName()
				); 
			} 
 
			entry = reassociate(event, entity, id, persister);
			cascadeOnLock(event, persister, entity);
		} 
 
		upgradeLock( entity, entry, event.getLockOptions(), event.getSession() );
	} 
	 
	private void cascadeOnLock(LockEvent event, EntityPersister persister, Object entity) {
		EventSource source = event.getSession();
Experience pair programming with AI  Get Codota for Java