All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ibatis.persist.impl.path.AttributePathImpl Maven / Gradle / Ivy

Go to download

The jBATIS persistence framework will help you to significantly reduce the amount of Java code that you normally need to access a relational database. iBATIS simply maps JavaBeans to SQL statements using a very simple XML descriptor.

The newest version!
package org.ibatis.persist.impl.path;

import org.ibatis.persist.meta.Attribute;
import org.ibatis.persist.criteria.Path;
import org.ibatis.persist.impl.CriteriaBuilderImpl;
import org.ibatis.persist.impl.PathImplementor;
import org.ibatis.persist.impl.PathSource;
import org.ibatis.persist.impl.RenderingContext;
import org.ibatis.persist.impl.expression.ExpressionImpl;

public class AttributePathImpl extends ExpressionImplimplements Path, PathImplementor {

    private final PathSource pathSource;

    private final Attribute attribute;

    public AttributePathImpl(CriteriaBuilderImpl criteriaBuilder, Class javaType, PathSource pathSource,
        Attribute attribute) {
        super(criteriaBuilder, javaType);
        this.pathSource = pathSource;
        this.attribute = attribute;
    }

    public PathSource getPathSource() {
        return pathSource;
    }

    @Override
    public void render(RenderingContext rc) {
        PathSource source = getPathSource();
        Attribute a = getAttribute();
        if (source != null && source.getPathAlias() != null) {
            rc.append(source.getPathAlias() + "." + a.getColumn());
        } else {
            rc.append(a.getColumn());
        }
    }

    @Override
    public void renderProjection(RenderingContext rc) {
        render(rc);
        if (getAlias() == null) {
            alias(getAttribute().getName());
        }
        rc.append(" AS ").append(getAlias());
    }

    @Override
    public Attribute getAttribute() {
        return attribute;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy