Java 类org.hibernate.annotations.Formula 实例源码

项目:asistente-eventos    文件:BolsaUtil.java   
public static boolean isFormula(Class<?> clazz, String property) {

        boolean ret = false;
        String key = clazz.getName() + "." + property;
        Boolean isForm = classFieldFormula.get(key);
        try {
            if (isForm == null) {
                Field field = clazz.getDeclaredField(property);
                Annotation[] anns = field.getAnnotations();
                for (Annotation ann : anns) {
                    // Buscamos entre las anotaciones para esta propiedad, si
                    // tiene
                    // Transient
                    ret = ann instanceof Formula;
                    if (ret)
                        break;
                }
                classFieldFormula.put(key, ret);
            } else
                ret = isForm;
        } catch (NoSuchFieldException e) {

            ret = isFormula(clazz.getSuperclass(), property);

            classFieldFormula.put(key, ret);
        }
        // log.debug("Clase: " + clazz.getSimpleName() + " , property: " +
        // property + ", isTransient: " + ret);
        return ret;
    }
项目:tekoporu-postgresql    文件:BolsaUtil.java   
public static boolean isFormula(Class<?> clazz, String property) {
    boolean ret = false;
    String key = clazz.getName() + "." + property;
    Boolean isForm = classFieldFormula.get(key);
    try {
        if (isForm == null) {
            Field field = clazz.getDeclaredField(property);
            Annotation[] anns = field.getAnnotations();
            for (Annotation ann : anns) {
                // Buscamos entre las anotaciones para esta propiedad, si
                // tiene
                // Transient
                ret = ann instanceof Formula;
                if (ret)
                    break;
            }
            classFieldFormula.put(key, ret);
        } else
            ret = isForm;
    } catch (NoSuchFieldException e) {

        ret = isFormula((Class<?>) clazz.getSuperclass(), property);

        classFieldFormula.put(key, ret);
    }
    // log.debug("Clase: " + clazz.getSimpleName() + " , property: " +
    // property + ", isTransient: " + ret);
    return ret;
}
项目:lams    文件:ColumnsBuilder.java   
public ColumnsBuilder extractMetadata() {
    columns = null;
    joinColumns = buildExplicitJoinColumns(property, inferredData);


    if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( Formula.class ) ) {
        Column ann = property.getAnnotation( Column.class );
        Formula formulaAnn = property.getAnnotation( Formula.class );
        columns = Ejb3Column.buildColumnFromAnnotation(
                new Column[] { ann }, formulaAnn, nullability, propertyHolder, inferredData,
                entityBinder.getSecondaryTables(), mappings
        );
    }
    else if ( property.isAnnotationPresent( Columns.class ) ) {
        Columns anns = property.getAnnotation( Columns.class );
        columns = Ejb3Column.buildColumnFromAnnotation(
                anns.columns(), null,
                nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(),
                mappings
        );
    }

    //set default values if needed
    if ( joinColumns == null &&
            ( property.isAnnotationPresent( ManyToOne.class )
                    || property.isAnnotationPresent( OneToOne.class ) )
            ) {
        joinColumns = buildDefaultJoinColumnsForXToOne(property, inferredData);
    }
    else if ( joinColumns == null &&
            ( property.isAnnotationPresent( OneToMany.class )
                    || property.isAnnotationPresent( ElementCollection.class )
            ) ) {
        OneToMany oneToMany = property.getAnnotation( OneToMany.class );
        String mappedBy = oneToMany != null ?
                oneToMany.mappedBy() :
                "";
        joinColumns = Ejb3JoinColumn.buildJoinColumns(
                null,
                mappedBy, entityBinder.getSecondaryTables(),
                propertyHolder, inferredData.getPropertyName(), mappings
        );
    }
    else if ( joinColumns == null && property.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
        throw new AnnotationException( "@Any requires an explicit @JoinColumn(s): "
                + BinderHelper.getPath( propertyHolder, inferredData ) );
    }
    if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) {
        //useful for collection of embedded elements
        columns = Ejb3Column.buildColumnFromAnnotation(
                null, null,
                nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings
        );
    }

    if ( nullability == Nullability.FORCED_NOT_NULL ) {
        //force columns to not null
        for (Ejb3Column col : columns ) {
            col.forceNotNull();
        }
    }
    return this;
}
项目:DWSurvey    文件:SurveyDirectory.java   
@Formula("(select o.name from t_user o where o.id = user_id)")
public String getUserName() {
    return userName;
}
项目:DWSurvey    文件:QuestionBank.java   
@Formula("(select o.name from t_user o where o.id = user_id)")
public String getUserName() {
    return userName;
}
项目:bag-database    文件:Bag.java   
@Column(name = "latitudeDeg")
@Formula("ST_Y(coordinate)")
public Double getLatitudeDeg() {
    return latitudeDeg;
}
项目:bag-database    文件:Bag.java   
@Column(name = "longitudeDeg")
@Formula("ST_X(coordinate)")
public Double getLongitudeDeg() {
    return longitudeDeg;
}
项目:elide    文件:Book.java   
/**
 * Demonstrates a more complex ranking use case.
 * @return The number of chapters in a book.
 */
@Formula(value = "(SELECT COUNT(*) FROM book AS b JOIN book_chapter AS bc ON bc.book_id = b.id WHERE id=b.id)")
public int getChapterCount() {
    return chapters.size();
}
项目:org.fastnate    文件:AccessStyle.java   
@Override
public boolean isPersistent() {
    final int modifiers = this.field.getModifiers();
    return !Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)
            && !isAnnotationPresent(Transient.class) && !isAnnotationPresent(Formula.class);
}
项目:org.fastnate    文件:AccessStyle.java   
@Override
public boolean isPersistent() {
    final int modifiers = this.method.getModifiers();
    return !Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)
            && !isAnnotationPresent(Transient.class) && !isAnnotationPresent(Formula.class);
}