📄 propertyexpression.java
字号:
//$Id: PropertyExpression.java,v 1.1.2.3 2003/10/27 11:46:58 oneovthafew Exp $
package net.sf.hibernate.expression;
import java.util.Map;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.engine.SessionFactoryImplementor;
import net.sf.hibernate.engine.TypedValue;
import net.sf.hibernate.util.StringHelper;
/**
* superclass for comparisons between two properties (with SQL binary operators)
* @author Gavin King
*/
public abstract class PropertyExpression extends AbstractCriterion {
private final String propertyName;
private final String otherPropertyName;
private static final TypedValue[] NO_TYPED_VALUES = new TypedValue[0];
PropertyExpression(String propertyName, String otherPropertyName) {
this.propertyName = propertyName;
this.otherPropertyName = otherPropertyName;
}
public String toSqlString(SessionFactoryImplementor sessionFactory, Class persistentClass, String alias, Map aliasClasses) throws HibernateException {
String[] xcols = getColumns(sessionFactory, persistentClass, propertyName, alias, aliasClasses);
String[] ycols = getColumns(sessionFactory, persistentClass, otherPropertyName, alias, aliasClasses);
String result = StringHelper.join(
" and ",
StringHelper.add(xcols, getOp(), ycols)
);
if (xcols.length>1) result = StringHelper.OPEN_PAREN + result + StringHelper.CLOSE_PAREN;
return result;
//TODO: get SQL rendering out of this package!
}
public TypedValue[] getTypedValues(SessionFactoryImplementor sessionFactory, Class persistentClass, Map aliasClasses) throws HibernateException {
return NO_TYPED_VALUES;
}
public String toString() {
return propertyName + getOp() + otherPropertyName;
}
abstract String getOp();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -