Persists the specified PersistenceCapable object.
@param object a PersistenceCapable object
@param <T> the type to return
@return the persisted object
545237
@SuppressWarnings("unchecked")
    public <T> T persist(T object) {
        pm.currentTransaction().begin();
        pm.makePersistent(object);
        pm.currentTransaction().commit();
        pm.getFetchPlan().setDetachmentOptions(FetchPlan.DETACH_LOAD_FIELDS);
        pm.refresh(object);
        return object;
    }
827740
public <T> Object writeObject(final T object, final DataTypeDescriptor<T> descriptor) {
		try {
			return objectFormat.write(object, descriptor);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
885980
public static Reflect onObject(Object object) {
      if (object == null) {
         return new Reflect(null, null);
      }
      return new Reflect(object, object.getClass());
   }
641291
public void addObject(final T _object)
    {
        final Map<Long, T> newCache4Id =  getNewCache4Id();
        final Map<String, T> newCache4Name = getNewCache4Name();
        final Map<UUID, T>  newCache4UUID = getNewCache4UUID();

        if (getCache4Id() != null) {
            newCache4Id.putAll(getCache4Id());
        }

        if (getCache4Name() != null) {
            newCache4Name.putAll(getCache4Name());
        }

        if (getCache4UUID() != null) {
            newCache4UUID.putAll(getCache4UUID());
        }

        newCache4Id.put(_object.getId(), _object);
        newCache4Name.put(_object.getName(), _object);
        newCache4UUID.put(_object.getUUID(), _object);

        // replace old cache with new values
        // it is thread save because of volatile
        setCache4Id(newCache4Id);
        setCache4Name(newCache4Name);
        setCache4UUID(newCache4UUID);
    }
870823
@SuppressWarnings("unchecked")
    protected <T extends IEntity> Object getSerializableObject(T object) throws FMSException {

        Class<?> objectClass = object.getClass();
        String methodName = "create".concat(objectClass.getSimpleName());
        ObjectFactory objectEntity = new ObjectFactory();
        Class<?> objectEntityClass = objectEntity.getClass();

        Method method = null;
        try {
            method = objectEntityClass.getMethod(methodName, Class.forName(objectClass.getName()));
        } catch (Exception e) {
            LOG.error("Exception while prepare the method signature using reflection to generate JAXBElement", e);
            throw new FMSException("Exception while prepare the method signature using reflection to generate JAXBElement", e);
        }
        JAXBElement<? extends IEntity> jaxbElement = null;
        try {
            jaxbElement = (JAXBElement<? extends IEntity>) method.invoke(objectEntity, object);
        } catch (Exception e) {
            LOG.error("Exception while invoking the method using reflection to generate JAXBElement", e);
            throw new FMSException("Exception while prepare the method signature using reflection to generate JAXBElement", e);
        }

        return jaxbElement;
    }
1065917
public static function persist(IdentifiableObject $object) : void
    {
        self::repositoryFor(\get_class($object))->persist($object);
    }
689471
public final <T> T saveObject(final T obj) throws Exception {
        return executeInTransaction(new Runnable<T>() {
            @Override
            public T run(final EntityManager entityManager) {
                return persist(obj, entityManager);
            }
        });
    }
910945
protected void _syncProperties(
                    final T object,
                    final T p_object
                    )
    {
        BeansUtil.copyPropertiesExcept(
                        p_object,
                        object,
                        new String[] { "persistentID" }
        );
    }
1055832
public final void setUserObject(T object) {
        if (userObject == null && object == null) {
            // no unnecessary property creation if everything is null
            return;
        }
        userObjectProperty().set(object);
    }
420158
public <T> T datastoreToJava(Entity entity) {
		try {
			if (entity == null) {
				return null;
			}
			T result = (T) persistentClass.newInstance();
			populate(entity, result);
			return result;
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
68169
@Override
    public void writeToObject(Object object) {
        try {
            Method method = BeanUtils.getWriteMethod(object.getClass(), getName());
            if (method != null) {
                method.invoke(object, new Object[]{getValue()});
            }
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
1138205
public <T extends BaseProxy> T editProxy(final T object) {
    AutoBean<T> bean = this.checkStreamsNotCrossed(object);
    this.checkLocked();

    @SuppressWarnings("unchecked")
    final AutoBean<T> previouslySeen =
        (AutoBean<T>) this.state.editedProxies.get(BaseProxyCategory.stableId(bean));
    if (previouslySeen != null && !previouslySeen.isFrozen()) {
      /*
       * If we've seen the object before, it might be because it was passed in as a method argument.
       * This does not guarantee its mutability, so check that here before returning the cached
       * object.
       */
      return previouslySeen.as();
    }

    // Create editable copies
    final AutoBean<T> parent = bean;
    bean = this.cloneBeanAndCollections(bean);
    bean.setTag(Constants.PARENT_OBJECT, parent);
    return bean.as();
  }
375978
public <T> T copy (T object) {
		if (object == null) return null;
		if (copyShallow) return object;
		copyDepth++;
		try {
			if (originalToCopy == null) originalToCopy = new IdentityMap();
			Object existingCopy = originalToCopy.get(object);
			if (existingCopy != null) return (T)existingCopy;

			if (copyReferences) needsCopyReference = object;
			Object copy;
			if (object instanceof KryoCopyable)
				copy = ((KryoCopyable)object).copy(this);
			else
				copy = getSerializer(object.getClass()).copy(this, object);
			if (needsCopyReference != null) reference(copy);
			if (TRACE || (DEBUG && copyDepth == 1)) log("Copy", copy, -1);
			return (T)copy;
		} finally {
			if (--copyDepth == 0) reset();
		}
	}
191368
public final byte[] serialize(Object object) throws IOException {
        if (object == null)
            return null;

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        SerializationService serializationSvc = serializationSvcRef.getServiceWithException();
        ObjectOutputStream oout = serializationSvc.createObjectOutputStream(new DeflaterOutputStream(bout));
        oout.writeObject(object);
        oout.flush();
        oout.close();
        byte[] bytes = bout.toByteArray();
        return bytes;
    }
627127
public <T> T convertValue(Object object, JavaType toValueTypeRef) {
		return this.mapper.convertValue(object, toValueTypeRef);
	}
90539
public static byte[] serialize(Object object) {
		
		byte[] result = null;
		
		if (object == null) {
			return new byte[0];
		}
		try {
			ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128);
			try  {
				if (!(object instanceof Serializable)) {
					throw new IllegalArgumentException(SerializeUtils.class.getSimpleName() + " requires a Serializable payload " +
							"but received an object of type [" + object.getClass().getName() + "]");
				}
				ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream);
				objectOutputStream.writeObject(object);
				objectOutputStream.flush();
				result =  byteStream.toByteArray();
			}
			catch (Throwable ex) {
				throw new Exception("Failed to serialize", ex);
			}
		} catch (Exception ex) {
			logger.error("Failed to serialize",ex);
		}
		return result;
	}
744600
public <T> T convert(Object object, Class<T> clazz) {
        if (object == null) {
            return null;
        }

        return mapper.convertValue(object, clazz);
    }