Package java.io

Examples of java.io.Serializable


    if (entity != null) {
      if (em().contains(entity)) {
        em().remove(entity);
        return true;
      } else {
        Serializable id = getMetadataUtil().getId(entity);
        return _removeById(entity.getClass(), id);
      }
    }
    return false;
  }
View Full Code Here


   * return array.
   */
  protected <T> T[] _find(Class<T> type, Serializable... ids) {
    Object[] retList = (Object[]) Array.newInstance(type, ids.length);
    for (Object entity : pullByIds("select _it_", type, ids)) {
      Serializable id = getMetadataUtil().getId(entity);

      for (int i = 0; i < ids.length; i++) {
        if (id.equals(ids[i])) {
          retList[i] = entity;
          // don't break. the same id could be in the list twice.
        }
      }
    }
View Full Code Here

  protected <T> T _persistOrMerge(T entity) {
    if (entity == null)
      return null;
    if (em().contains(entity))
      return entity;
    Serializable id = getMetadataUtil().getId(entity);
    if (!validId(id)) {
      _persist(entity);
      return entity;
    }
    T prev = em().find((Class<T>) entity.getClass(), id);
View Full Code Here

   */
  protected boolean _saveOrUpdateIsNew(Object entity) {
    if (entity == null)
      throw new IllegalArgumentException("attempt to saveOrUpdate with null entity");

    Serializable id = getMetadataUtil().getId(entity);
    if (getSession().contains(entity))
      return false;

    if (id == null || (new Long(0)).equals(id) || !_exists(entity)) {
      _save(entity);
View Full Code Here

        throw new IllegalArgumentException("attempt to saveOrUpdate with null entity");
      }
      if (getSession().contains(entities[i])) {
        exists[i] = true;
      } else {
        Serializable id = getMetadataUtil().getId(entities[i]);
        if (id == null || (new Long(0)).equals(id)) {
          exists[i] = false;
        }
      }
    }
View Full Code Here

   * @return <code>true</code> if the object is found in the datastore and
   *         removed, <code>false</code> if the item is not found.
   */
  protected boolean _deleteEntity(Object entity) {
    if (entity != null) {
      Serializable id = getMetadataUtil().getId(entity);
      if (id != null) {
        entity = getSession().get(metadataUtil.getUnproxiedClass(entity), id);
        if (entity != null) {
          getSession().delete(entity);
          return true;
View Full Code Here

    Criteria c = getSession().createCriteria(type);
    c.add(Restrictions.in("id", ids));
    Object[] retVal = (Object[]) Array.newInstance(type, ids.length);

    for (Object entity : c.list()) {
      Serializable id = getMetadataUtil().getId(entity);
      for (int i = 0; i < ids.length; i++) {
        if (id.equals(ids[i])) {
          retVal[i] = entity;
          break;
        }
      }
    }
View Full Code Here

                if (logger.isTraceEnabled()) {
                    logger.trace("["+connectionID+"] Server message received: " +event + ";" + messageData.charAt(0));
                }
                if (event.equals("o")) {
                    if (messageData.charAt(0) == 'p') {
                        Serializable message = deserialize(messageData.substring(1));
                        if (message != null) {
                            postMessages.add(message);
                        }
                    } else if (messageData.charAt(0) == 'b') {
                        Serializable message = deserialize(messageData.substring(1));
                        broadcast(message, resource);
                    }
                   
                } else if (event.equals("s")) {
                   
                    if (messageData.charAt(0) == 'p') {
                        String message = messageData.substring(1);
                        postMessages.add(message);
                    } else if (messageData.charAt(0) == 'b') {
                        Serializable message = messageData.substring(1);
                        broadcast(message, resource);
                    }
                   
                } else if (event.equals("c")) {
                   
View Full Code Here

          "Object class does not match dao type.");
    _save(object);
  }

  public boolean createOrUpdate(T object) {
    Serializable id = getMetadataUtil().getId(object);
    if (id == null || (new Long(0)).equals(id)) {
      create(object);
      return true;
    } else {
      update(object);
View Full Code Here

  public void create(Object object) {
    _save(object);
  }

  public boolean createOrUpdate(Object object) {
    Serializable id = getMetadataUtil().getId(object);
    if (id == null || (new Long(0)).equals(id)) {
      create(object);
      return true;
    } else {
      update(object);
View Full Code Here

TOP

Related Classes of java.io.Serializable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.