/** Return the value of the property method. */
 public Object getValue(EntityBean bean) {
   try {
     return getter.get(bean);
   } catch (Exception ex) {
     String beanType = bean == null ? "null" : bean.getClass().getName();
     String msg = "get " + name + " on [" + descriptor + "] type[" + beanType + "] threw error.";
     throw new RuntimeException(msg, ex);
   }
 }
Esempio n. 2
0
  protected void executeDerivedRelationships() {
    List<DerivedRelationshipData> derivedRelationships = persistRequest.getDerivedRelationships();
    if (derivedRelationships != null) {

      SpiEbeanServer ebeanServer = (SpiEbeanServer) persistRequest.getEbeanServer();

      for (int i = 0; i < derivedRelationships.size(); i++) {
        DerivedRelationshipData derivedRelationshipData = derivedRelationships.get(i);

        BeanDescriptor<?> beanDescriptor =
            ebeanServer.getBeanDescriptor(derivedRelationshipData.getBean().getClass());

        BeanProperty prop =
            beanDescriptor.getBeanProperty(derivedRelationshipData.getLogicalName());
        EntityBean entityBean = (EntityBean) derivedRelationshipData.getBean();
        entityBean._ebean_getIntercept().markPropertyAsChanged(prop.getPropertyIndex());

        ebeanServer.update(entityBean, transaction);
      }
    }
  }
 /** Return an error message when calling a setter. */
 private String setterErrorMsg(EntityBean bean, Object value, String prefix) {
   String beanType = bean == null ? "null" : bean.getClass().getName();
   return prefix
       + name
       + " on ["
       + descriptor
       + "] arg["
       + value
       + "] type["
       + beanType
       + "] threw error";
 }
 /**
  * Set the changed value without invoking interception (lazy loading etc). Typically used to set
  * generated values on update.
  */
 public void setValueChanged(EntityBean bean, Object value) {
   setValue(bean, value);
   bean._ebean_getIntercept().setChangedProperty(propertyIndex);
 }
 /** Set the soft delete property value on the bean without invoking lazy loading. */
 public void setSoftDeleteValue(EntityBean bean) {
   // assumes boolean deleted true being set which is ok limitation for now
   setValue(bean, true);
   bean._ebean_getIntercept().setChangedProperty(propertyIndex);
 }