code: @Override
      protected void onPersist(EntityMetadata metadata, Object entity, Object id, List<RelationHolder> relationHolders)
      {
          boolean proxyRemoved = removeKunderaProxies(metadata, entity, relationHolders);
  
          Transaction tx = null;
  
          s = getStatelessSession();
          tx = onBegin();
          try
          {
              if (!isUpdate)
              {
                  id = s.insert(entity);
  
                  // Update foreign Keys
                  updateForeignKeys(metadata, id, relationHolders);
                  onCommit(tx);/* tx.commit(); */
              }
              else
              {
                  s.update(entity);
  
                  if (proxyRemoved)
                  {
                      updateForeignKeys(metadata, id, relationHolders);
                  }
  
                  onCommit(tx);
              }
          }
          // TODO: Bad code, get rid of these exceptions, currently necessary for
          // handling many to one case
          catch (org.hibernate.exception.ConstraintViolationException e)
          {
              s.update(entity);
              log.info(e.getMessage());
              onCommit(tx);
              // tx.commit();
          }
          catch (HibernateException e)
          {
              log.error("Error while persisting object of {}, Caused by {}.", metadata.getEntityClazz(), e);
              throw new PersistenceException(e);
          }
      }
docs: /*
  (non-Javadoc)
  
  @see
  com.impetus.kundera.client.ClientBase#onPersist(com.impetus.kundera.metadata
  .model.EntityMetadata, java.lang.Object, java.lang.Object,
  java.util.List)