org.springframework.data.annotation.Transient Java Examples

The following examples show how to use org.springframework.data.annotation.Transient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestTransformationStepVO.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
@Transient
@Override
public RestTransformationStepVO apply(TransformationStep t) {
    RestTransformationStepVO r = new RestTransformationStepVO();
    r.setType(IntegrationType.REST);
    r.setMethod((String) t.getAttributes()
            .get(RestTransformationStep.REST_ATTRIBUTE_METHOD));
    r.setUsername((String) t.getAttributes()
            .get(RestTransformationStep.REST_USERNAME_ATTRIBUTE_NAME));
    r.setPassword((String) t.getAttributes()
            .get(RestTransformationStep.REST_PASSWORD_ATTRIBUTE_NAME));
    r.setUrl((String) t.getAttributes()
            .get(RestTransformationStep.REST_URL_ATTRIBUTE_NAME));
    r.setHeaders((Map) t.getAttributes()
            .get(RestTransformationStep.REST_ATTRIBUTE_HEADERS));
    return r;
}
 
Example #2
Source File: Tree.java    From Dodder with MIT License 5 votes vote down vote up
/**
 * 构建叶子节点数组,实际上就是构建子文件列表
 * @return
 */
@Transient
public List<Node> getLeafList() {
	leaves = new ArrayList<>();
	deep(root);
	return leaves;
}
 
Example #3
Source File: SqlUtil.java    From base-admin with MIT License 5 votes vote down vote up
/**
 *
 * @param entity 自动拼接实体对象字段
 * @param ignoreProperties 动态参数  忽略拼接的字段
 * @return sql
 */
public static StringBuilder appendFields(Object entity, String... ignoreProperties) {
    StringBuilder sql = new StringBuilder();
    List<String> ignoreList = Arrays.asList(ignoreProperties);
    try {
        sql.append("select ");

        for (Field field : entity.getClass().getDeclaredFields()) {
            //获取授权
            field.setAccessible(true);
            String fieldName = field.getName();//属性名称
            Object fieldValue = field.get(entity);//属性的值
            //非临时字段、非忽略字段
            if (!field.isAnnotationPresent(Transient.class) && !ignoreList.contains(fieldName)) {
                //拼接查询字段  驼峰属性转下划线
                sql.append(new PropertyNamingStrategy.SnakeCaseStrategy().translate(fieldName).toLowerCase()).append(" ").append(",");
            }
        }
        //处理逗号(删除最后一个字符)
        sql.deleteCharAt(sql.length() - 1);

        String tableName = entity.getClass().getAnnotation(Table.class).name();
        sql.append("from ").append(tableName).append(" where '1' = '1' ");
    } catch (IllegalAccessException e) {
        //输出到日志文件中
        log.error(ErrorUtil.errorInfoToString(e));
    }
    return sql;
}
 
Example #4
Source File: RestTransformationVO.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Transient
@Override
public RestTransformationVO apply(Transformation t) {
    RestTransformationVO r = new RestTransformationVO();
    r.setId(t.getId());
    r.setGuid(t.getGuid());
    r.setName(t.getName());
    r.setDescription(t.getDescription());
    r.setSteps(new RestTransformationStepVO().apply(t.getSteps()));
    return r;
}
 
Example #5
Source File: SerializableVO.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Serialize list of objects from DB to VO
 * @param t
 * @return List<R>
 */
@Transient
default List<R> apply(List<T> t) {
    return t.parallelStream()
                .map(this::apply)
                .collect(Collectors.toList());

}
 
Example #6
Source File: SqlUtil.java    From base-admin with MIT License 4 votes vote down vote up
/**
 * 自动拼接原生SQL的“and”查询条件,支持自定义注解:@Like @Between @In
 *
 * @param entity           实体对象
 * @param sql              待拼接SQL
 * @param ignoreProperties 忽略属性
 */
public static void appendQueryColumns(Object entity, StringBuilder sql, String... ignoreProperties) {

    try {
        //忽略属性
        List<String> ignoreList1 = Arrays.asList(ignoreProperties);
        //默认忽略分页参数
        List<String> ignoreList2 = Arrays.asList("class", "pageable", "page", "rows", "sidx", "sord");

        //反射获取Class的属性(Field表示类中的成员变量)
        for (Field field : entity.getClass().getDeclaredFields()) {
            //获取授权
            field.setAccessible(true);
            //属性名称
            String fieldName = field.getName();
            //属性的值
            Object fieldValue = field.get(entity);
            //检查Transient注解,是否忽略拼接
            if (!field.isAnnotationPresent(Transient.class)) {
                String column = new PropertyNamingStrategy.SnakeCaseStrategy().translate(fieldName).toLowerCase();
                //值是否为空
                if (!StringUtils.isEmpty(fieldValue)) {
                    //映射关系:对象属性(驼峰)->数据库字段(下划线)
                    if (!ignoreList1.contains(fieldName) && !ignoreList2.contains(fieldName)) {
                        //开启模糊查询
                        if (field.isAnnotationPresent(Like.class)) {
                            sql.append(" and " + column + " like '%" + fieldValue + "%'");
                        }
                        //开启等值查询
                        else {
                            sql.append(" and " + column + " = '" + fieldValue + "'");
                        }
                    }
                } else {
                    //开启区间查询
                    if (field.isAnnotationPresent(Between.class)) {
                        //获取最小值
                        Field minField = entity.getClass().getDeclaredField(field.getAnnotation(Between.class).min());
                        minField.setAccessible(true);
                        Object minVal = minField.get(entity);
                        //获取最大值
                        Field maxField = entity.getClass().getDeclaredField(field.getAnnotation(Between.class).max());
                        maxField.setAccessible(true);
                        Object maxVal = maxField.get(entity);
                        //开启区间查询
                        if (field.getType().getName().equals("java.util.Date")) {
                            //MySQL
                            if(sqlType.toLowerCase().contains("mysql")){

                            }
                            //Oracle
                            if(sqlType.toLowerCase().contains("oracle")){
                                if (!StringUtils.isEmpty(minVal)) {
                                    sql.append(" and " + column + " > to_date( '" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) minVal) + "','yyyy-mm-dd hh24:mi:ss')");
                                }
                                if (!StringUtils.isEmpty(maxVal)) {
                                    sql.append(" and " + column + " < to_date( '" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) maxVal) + "','yyyy-mm-dd hh24:mi:ss')");
                                }
                            }
                        }
                    }

                    //开启in查询
                    if (field.isAnnotationPresent(In.class)) {
                        //获取要in的值
                        Field values = entity.getClass().getDeclaredField(field.getAnnotation(In.class).values());
                        values.setAccessible(true);
                        List<String> valuesList = (List<String>) values.get(entity);
                        if (valuesList != null && valuesList.size() > 0) {
                            String inValues = "";
                            for (String value : valuesList) {
                                inValues = inValues + "'" + value + "'";
                            }
                            sql.append(" and " + column + " in (" + inValues + ")");
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        //输出到日志文件中
        log.error(ErrorUtil.errorInfoToString(e));
    }
}
 
Example #7
Source File: CalendarUser.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
@JsonIgnore
@Transient
public void addRole(Role role){
    this.roles.add(role);
}
 
Example #8
Source File: MavenLibrary.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@JsonIgnore
@Transient
public String getCoordinate() {
	return String.format("%s:%s:%s", groupid, artifactid, version);
}
 
Example #9
Source File: TemperatureReading.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Transient
public boolean isNormal() {
	return !(isBoiling() || isFreezing());
}
 
Example #10
Source File: Book.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Transient
public boolean isNew() {
	return getIsbn() == null;
}
 
Example #11
Source File: DynamoDBPersistentPropertyImpl.java    From spring-data-dynamodb with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTransient() {
	return isAnnotationPresent(Transient.class) || super.isTransient() || isAnnotationPresent(DynamoDBIgnore.class);
}
 
Example #12
Source File: MetadataParser.java    From spring-data-simpledb with MIT License 4 votes vote down vote up
private static boolean isTransientField(Field field) {
	return field.isAnnotationPresent(Transient.class);
}
 
Example #13
Source File: TemperatureReading.java    From spring-boot-data-geode with Apache License 2.0 3 votes vote down vote up
@Transient
public boolean isBoiling() {

	Integer temperature = getTemperature();

	return temperature != null && temperature >= BOILING_TEMPERATURE;
}
 
Example #14
Source File: TemperatureReading.java    From spring-boot-data-geode with Apache License 2.0 3 votes vote down vote up
@Transient
public boolean isFreezing() {

	Integer temperature = getTemperature();

	return temperature != null && temperature <= FREEZING_TEMPERATURE;
}
 
Example #15
Source File: CalendarUser.java    From Spring-Security-Third-Edition with MIT License 2 votes vote down vote up
/**
 * Gets the full name in a formatted fashion. Note in a real application a formatter may be more appropriate, but in
 * this application simplicity is more important.
 *
 * @return
 */
@JsonIgnore
@Transient
public String getName() {
    return getEmail();
}