org.ibatis.persist.impl.expression.SelectionImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbatis Show documentation
Show all versions of jbatis Show documentation
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.expression;
import java.util.Collections;
import java.util.List;
import org.ibatis.persist.criteria.Selection;
import org.ibatis.persist.impl.AbstractNode;
import org.ibatis.persist.impl.CriteriaBuilderImpl;
import org.ibatis.persist.impl.RenderingContext;
import org.ibatis.persist.impl.SelectionImplementor;
import com.ibatis.sqlmap.engine.type.TypeHandler;
@SuppressWarnings("unchecked")
public abstract class SelectionImpl extends AbstractNode
implements SelectionImplementor {
public SelectionImpl(CriteriaBuilderImpl criteriaBuilder, Class javaType) {
super( criteriaBuilder );
this.originalJavaType = javaType;
this.javaType = javaType;
}
public Selection alias(String alias) {
setAlias( alias );
return this;
}
public boolean isCompoundSelection() {
return false;
}
public List> getValueHandlers() {
TypeHandler hander = getValueHandler();
if (hander == null) {
return null;
}
List> list = Collections.singletonList(hander);
return (List>) list;
}
public List> getCompoundSelectionItems() {
throw new IllegalStateException( "Not a compound selection" );
}
final Class originalJavaType;
private Class javaType;
private String alias;
private TypeHandler valueHandler;
@Override
public Class getJavaType() {
return javaType;
}
public void setJavaType(Class targetType) {
this.javaType = targetType;
this.valueHandler = (TypeHandler) criteriaBuilder().getEntityManager().getDelegate().getTypeHandlerFactory().getTypeHandler(javaType);
}
protected void forceConversion(TypeHandler valueHandler) {
this.valueHandler = valueHandler;
}
@Override
public TypeHandler getValueHandler() {
return valueHandler;
}
@Override
public String getAlias() {
return alias;
}
/**
* Protected access to define the alias.
*
* @param alias The alias to use.
*/
protected void setAlias(String alias) {
this.alias = alias;
}
@Override
public void renderFrom(RenderingContext rc) {
throw new IllegalStateException( "Selection cannot occur in from clause" );
}
}