Examples of SienaException


Examples of siena.SienaException

      switch(id.value()) {
      case NONE:
        Object idVal = null;
        idVal = Util.readField(obj, idField);
        if(idVal == null)
          throw new SienaException("Id Field " + idField.getName() + " value null");
        String keyVal = Util.toString(idField, idVal);       
        entity = new Entity(info.tableName, keyVal);
        break;
      case AUTO_INCREMENT:
        // manages String ID as not long!!!
        if(Long.TYPE == type || Long.class.isAssignableFrom(type)){
          entity = new Entity(info.tableName);
        }else {
          Object idStringVal = null;
          idStringVal = Util.readField(obj, idField);
          if(idStringVal == null)
            throw new SienaException("Id Field " + idField.getName() + " value null");
          String keyStringVal = Util.toString(idField, idStringVal);       
          entity = new Entity(info.tableName, keyStringVal);
        }
        break;
      case UUID:
        entity = new Entity(info.tableName, UUID.randomUUID().toString());
        break;
      default:
        throw new SienaRestrictedApiException("DB", "createEntityInstance", "Id Generator "+id.value()+ " not supported");
      }
    }
    else throw new SienaException("Field " + idField.getName() + " is not an @Id field");
   
    return entity;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.