Examples of DecimalPrecision


Examples of siena.core.DecimalPrecision

      Max max = field.getAnnotation(Max.class);
      if(max == null)
        column.setSize(""+255); // fixes by default to this value in order to prevent alter tables every time
      else column.setSize(""+max.value());
    } else if(type == BigDecimal.class){           
      DecimalPrecision an = field.getAnnotation(DecimalPrecision.class);
      if(an == null) {
        columnType = Types.DECIMAL;
        column.setSizeAndScale(19, 2);
      }
      else {
        if(an.storageType() == DecimalPrecision.StorageType.NATIVE){
          columnType = Types.DECIMAL;
          column.setSizeAndScale(an.size(), an.scale());
        }else if(an.storageType() == DecimalPrecision.StorageType.STRING) {
          columnType = Types.VARCHAR;
          // should be an.size+"."+sign
          column.setSize((an.size()+2)+"");
        }else if(an.storageType() == DecimalPrecision.StorageType.DOUBLE) {
          columnType = Types.DOUBLE;         
        }else {
          columnType = Types.DECIMAL;
          column.setSizeAndScale(19, 2);
        }
View Full Code Here

Examples of siena.core.DecimalPrecision

    } else if(type == byte[].class){
      return Types.BLOB;
    } else if(Enum.class.isAssignableFrom(type)){
      return Types.VARCHAR;
    } else if(type == BigDecimal.class){           
      DecimalPrecision an = field.getAnnotation(DecimalPrecision.class);
      if(an == null) {
        return Types.DECIMAL;
      }
      else {
        if(an.storageType() == DecimalPrecision.StorageType.NATIVE){
          return Types.DECIMAL;
        }else if(an.storageType() == DecimalPrecision.StorageType.STRING) {
          return Types.VARCHAR;
        }else if(an.storageType() == DecimalPrecision.StorageType.DOUBLE) {
          return Types.DOUBLE;         
        }else {
          return Types.DECIMAL;
        }
      }
View Full Code Here

Examples of siena.core.DecimalPrecision

      ByteArrayInputStream bis = new ByteArrayInputStream((byte[])value);
      ps.setBlob(index, bis);
    } else if(Enum.class.isAssignableFrom(type)){
      ps.setString(index, (String)value);
    } else if(type == BigDecimal.class){           
      DecimalPrecision an = field.getAnnotation(DecimalPrecision.class);
      if(an == null) {
        ps.setObject(index, value);
      }
      else {
        if(an.storageType() == DecimalPrecision.StorageType.NATIVE){
          ps.setBigDecimal(index, (BigDecimal)value);
        }else if(an.storageType() == DecimalPrecision.StorageType.STRING) {
          ps.setString(index, ((BigDecimal)value).toPlainString());
        }else if(an.storageType() == DecimalPrecision.StorageType.DOUBLE) {
          ps.setDouble(index, ((BigDecimal)value).doubleValue());
        }else {
          ps.setBigDecimal(index, (BigDecimal)value);
        }
      }
View Full Code Here

Examples of siena.core.DecimalPrecision

          }
          else if(Enum.class.isAssignableFrom(type)){
            value = value.toString();
          }
          else if(BigDecimal.class == type){
            DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
            if(ann == null) {
              value = (BigDecimal)value;
            }else {
              switch(ann.storageType()){
              case DOUBLE:
                value = ((BigDecimal)value).doubleValue();
                break;
              case STRING:
                value = ((BigDecimal)value).toPlainString();
View Full Code Here

Examples of siena.core.DecimalPrecision

      } catch (SQLException e) {
        throw new SienaException(e);
      }
    }
    if(BigDecimal.class == type){
      DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
      if(ann==null){
        return (BigDecimal)value;
      }else {
        switch(ann.storageType()){
        case DOUBLE:
          return BigDecimal.valueOf((Double)value);
        case STRING:
          return new BigDecimal((String)value);
        case NATIVE:
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.