Package com.avaje.ebean.bean

Examples of com.avaje.ebean.bean.EntityBeanIntercept


                // build a single object graph, and another thread has since
                // loaded a matching bean so we will use that instead.
                ref = existingBean;
               
            } else {
                EntityBeanIntercept ebi = ((EntityBean) ref)._ebean_getIntercept();
                if (Boolean.TRUE.equals(ctx.isReadOnly())){
                    ebi.setReadOnly(true);
                }
                ctx.register(name, ebi);
            }

            return ref;
View Full Code Here


            if (existing != null) {
                return existing;
            }
            Object ref = targetDescriptor.createReference(ctx.isReadOnly(), id);
           
            EntityBeanIntercept ebi = ((EntityBean) ref)._ebean_getIntercept();
            if (Boolean.TRUE.equals(ctx.isReadOnly())) {
                ebi.setReadOnly(true);
            }
            persistCtx.put(id, ref);
            ctx.register(name, ebi);
            return ref;
        }
View Full Code Here

      this.idPropertyIndex = -1;
      this.versionPropertyIndex = -1;
      this.unloadProperties = new int[0];
     
    } else {
      EntityBeanIntercept ebi = prototypeEntityBean._ebean_getIntercept();
      this.idPropertyIndex = (idProperty == null) ? -1 : ebi.findProperty(idProperty.getName());
      this.versionPropertyIndex = (versionProperty == null) ? -1 : ebi.findProperty(versionProperty.getName());
      this.unloadProperties = derivePropertiesToUnload(prototypeEntityBean);
    }
  }
View Full Code Here

    try {
      EntityBean bean = (EntityBean)prototypeEntityBean._ebean_newInstance();
     
      if (unloadProperties.length > 0) {
        // 'unload' any properties initialised in the default constructor
        EntityBeanIntercept ebi = bean._ebean_getIntercept();
        for (int i = 0; i < unloadProperties.length; i++) {
          ebi.setPropertyUnloaded(unloadProperties[i]);
        }
      }
      return bean;
     
    } catch (Exception ex) {
View Full Code Here

    try {
      EntityBean eb = createEntityBean();

      convertSetId(id, eb);

      EntityBeanIntercept ebi = eb._ebean_getIntercept();
      ebi.setBeanLoader(ebeanServer);

      // Note: not creating proxies for many's...
      ebi.setReference(idPropertyIndex);

      return (T) eb;

    } catch (Exception ex) {
      throw new PersistenceException(ex);
View Full Code Here

      // not in cache so return unsuccessful
      return false;
    }
   
    Object ownerBean = bc.getOwnerBean();
    EntityBeanIntercept ebi = ((EntityBean) ownerBean)._ebean_getIntercept();
    PersistenceContext persistenceContext = ebi.getPersistenceContext();

    BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();

    List<Object> idList = entry.getIdList();
    bc.checkEmptyLazyLoad();
    for (int i = 0; i < idList.size(); i++) {
      Object id = idList.get(i);
      Object refBean = targetDescriptor.createReference(readOnly, id);
      EntityBeanIntercept refEbi = ((EntityBean) refBean)._ebean_getIntercept();

      many.add(bc, (EntityBean) refBean);
      persistenceContext.put(id, refBean);
      refEbi.setPersistenceContext(persistenceContext);
    }
    return true;
  }
View Full Code Here

    }

    // Not using a loadContext for beans coming out of L2 cache
    // so that means no batch lazy loading for these beans
    EntityBean entityBean = (EntityBean)bean;
    EntityBeanIntercept ebi = entityBean._ebean_getIntercept();
    ebi.setPersistenceContext(context);
    Object id = desc.getId(entityBean);
    context.put(id, bean);

  }
View Full Code Here

      }
    }

    EntityBean bean = desc.createEntityBean();
    desc.convertSetId(id, bean);
    EntityBeanIntercept ebi = bean._ebean_getIntercept();
    ebi.setBeanLoader(desc.getEbeanServer());
   
    if (Boolean.TRUE.equals(readOnly)) {
      ebi.setReadOnly(true);
    }

    beanLoadData(bean, data);
   
    if (beanLog.isTraceEnabled()) {
View Full Code Here

  private SpiUpdatePlan getDynamicUpdatePlan(ConcurrencyMode mode, PersistRequestBean<?> persistRequest) {


    // we can use a cached UpdatePlan for the changed properties
   
    EntityBeanIntercept ebi = persistRequest.getEntityBeanIntercept();
    int hash = ebi.getDirtyPropertyHash();
   
    BeanDescriptor<?> beanDescriptor = persistRequest.getBeanDescriptor();
   
    BeanProperty versionProperty = beanDescriptor.getVersionProperty();
    if (versionProperty != null) {
      if (ebi.isLoadedProperty(versionProperty.getPropertyIndex())) {
        hash = hash * 31 + 7;
      }
    }

    Integer key = Integer.valueOf(hash);
View Full Code Here

  public void testEmbeddedUpdateEmbeddedProperty() {
   
    EMain emain = new EMain();

    EntityBean eb = (EntityBean)emain;
    EntityBeanIntercept ebi = eb._ebean_getIntercept();

    emain.setId(1);
    emain.setName("foo");
    Eembeddable embeddable = setEmbeddedBean(emain, "bar");
    setEmbeddedLoaded(embeddable);
   
    // sets loaded state so follow setters are deemed as changes to the bean
    ebi.setLoaded();
   
    emain.setName("changedFoo");
   
    DefaultBeanState beanState = new DefaultBeanState(eb);
   
View Full Code Here

TOP

Related Classes of com.avaje.ebean.bean.EntityBeanIntercept

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.