org.ibatis.persist.impl.expression.CompoundSelectionImpl 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.ArrayList;
import java.util.List;
import org.ibatis.persist.criteria.CompoundSelection;
import org.ibatis.persist.criteria.Selection;
import org.ibatis.persist.impl.CriteriaBuilderImpl;
import org.ibatis.persist.impl.Renderable;
import org.ibatis.persist.impl.RenderingContext;
import org.ibatis.persist.impl.SelectionImplementor;
import com.ibatis.sqlmap.engine.type.TypeHandler;
/**
* The Hibernate implementation of the JPA {@link CompoundSelection}
* contract.
*/
@SuppressWarnings("unchecked")
public class CompoundSelectionImpl
extends SelectionImpl
implements CompoundSelection {
private List> selectionItems;
public CompoundSelectionImpl(
CriteriaBuilderImpl criteriaBuilder,
Class javaType,
List> selectionItems) {
super( criteriaBuilder, javaType );
this.selectionItems = selectionItems;
}
@Override
public boolean isCompoundSelection() {
return true;
}
@Override
public List> getCompoundSelectionItems() {
return selectionItems;
}
@Override
public List> getValueHandlers() {
boolean foundHandlers = false;
ArrayList> valueHandlers = new ArrayList>();
for (Selection selection : getCompoundSelectionItems()) {
TypeHandler> valueHandler = ((SelectionImplementor) selection).getValueHandler();
valueHandlers.add(valueHandler);
foundHandlers = foundHandlers || valueHandler != null;
}
return foundHandlers ? null : valueHandlers;
}
public void render(RenderingContext rc) {
throw new IllegalStateException( "Compound selection cannot occur in expressions" );
}
public void renderProjection(RenderingContext rc) {
String sep = "";
for (Selection selection : selectionItems) {
rc.append(sep);
((Renderable) selection).renderProjection(rc);
sep = ", ";
}
}
}