Package com.avaje.ebeaninternal.api.SpiQuery

Examples of com.avaje.ebeaninternal.api.SpiQuery.Mode


      localDesc = desc;
      localBean = desc.createEntityBean();
      localIdBinder = idBinder;
    }

    Mode queryMode = ctx.getQueryMode();

    PersistenceContext persistenceContext = !readId ? null : ctx.getPersistenceContext();

    Object id = null;
    if (!readId) {
      // report type bean... or perhaps excluding the id for SqlSelect?

    } else {
      id = localIdBinder.readSet(ctx, localBean);
      if (id == null) {
        // bean must be null...
        localBean = null;
      } else {
        // check the PersistenceContext to see if the bean already exists
        contextBean = (EntityBean)persistenceContext.putIfAbsent(id, localBean);
        if (contextBean == null) {
          // bean just added to the persistenceContext
          contextBean = localBean;
        } else {
          // bean already exists in persistenceContext
          if (isLoadContextBeanNeeded(queryMode, contextBean)){
            // refresh it anyway (lazy loading for example)
            localBean = contextBean;
          } else {
            // ignore the DB data...
            localBean = null;
          }
        }
      }
    }

    ctx.setCurrentPrefix(prefix, pathMap);

    ctx.propagateState(localBean);

    SqlBeanLoad sqlBeanLoad = new SqlBeanLoad(ctx, localType, localBean, queryMode);

    if (inheritInfo == null) {
      // normal behavior with no inheritance
      for (int i = 0, x = properties.length; i < x; i++) {
        properties[i].load(sqlBeanLoad);
      }

    } else {
      // take account of inheritance and due to subclassing approach
      // need to get a 'local' version of the property
      for (int i = 0, x = properties.length; i < x; i++) {
        // get a local version of the BeanProperty
        BeanProperty p = localDesc.getBeanProperty(properties[i].getName());
        if (p != null) {
          p.load(sqlBeanLoad);
        } else {
          properties[i].loadIgnore(ctx);
        }
      }
    }

    for (int i = 0, x = tableJoins.length; i < x; i++) {
      tableJoins[i].load(sqlBeanLoad);
    }

    boolean lazyLoadMany = false;
    if (localBean == null && queryMode.equals(Mode.LAZYLOAD_MANY)) {
      // batch lazy load many into existing contextBean
      localBean = contextBean;
      lazyLoadMany = true;
    }
View Full Code Here

TOP

Related Classes of com.avaje.ebeaninternal.api.SpiQuery.Mode

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.