org.eclipse.persistence.internal.expressions.QueryKeyExpression.addDerivedExpression()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(58)

本文整理了Java中org.eclipse.persistence.internal.expressions.QueryKeyExpression.addDerivedExpression方法的一些代码示例,展示了QueryKeyExpression.addDerivedExpression的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryKeyExpression.addDerivedExpression方法的具体详情如下:
包路径:org.eclipse.persistence.internal.expressions.QueryKeyExpression
类名称:QueryKeyExpression
方法名:addDerivedExpression

QueryKeyExpression.addDerivedExpression介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * ADVANCED:
 * Return an expression that allows you to treat its base as if it were a subclass of the class returned by the base
 * This can only be called on an ExpressionBuilder, the result of expression.get(String), expression.getAllowingNull(String),
 * the result of expression.anyOf("String") or the result of expression.anyOfAllowingNull("String")
 *
 * downcast uses Expression.type() internally to guarantee the results are of the specified class.
 * <p>Example:
 * <pre><blockquote>
 *     EclipseLink: employee.get("project").treat(LargeProject.class).get("budget").equal(1000)
 *     Java: ((LargeProject)employee.getProjects().get(0)).getBudget() == 1000
 *     SQL: LPROJ.PROJ_ID (+)= PROJ.PROJ_ID AND L_PROJ.BUDGET = 1000 AND PROJ.TYPE = "L"
 * </blockquote></pre>
 */
@Override
public Expression treat(Class castClass){
  //to be used in 'where treat(t as PerformanceTireInfo).speedRating > 100'
  QueryKeyExpression clonedExpression = new TreatAsExpression(castClass, this);
  clonedExpression.shouldQueryToManyRelationship = this.shouldQueryToManyRelationship;
  //using shouldUseOuterJoin to indicate the join to use between the t and PerformanceTireInfo subclass.
  clonedExpression.hasQueryKey = this.hasQueryKey;
  clonedExpression.hasMapping = this.hasMapping;
  this.addDerivedExpression(clonedExpression);
  return clonedExpression;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * ADVANCED:
 * Return an expression that allows you to treat its base as if it were a subclass of the class returned by the base
 * This can only be called on an ExpressionBuilder, the result of expression.get(String), expression.getAllowingNull(String),
 * the result of expression.anyOf("String") or the result of expression.anyOfAllowingNull("String")
 * 
 * downcast uses Expression.type() internally to guarantee the results are of the specified class.
 * <p>Example:
 * <pre><blockquote>
 *     EclipseLink: employee.get("project").treat(LargeProject.class).get("budget").equal(1000)
 *     Java: ((LargeProject)employee.getProjects().get(0)).getBudget() == 1000
 *     SQL: LPROJ.PROJ_ID (+)= PROJ.PROJ_ID AND L_PROJ.BUDGET = 1000 AND PROJ.TYPE = "L"
 * </blockquote></pre>
 */
@Override
public Expression treat(Class castClass){
  //to be used in 'where treat(t as PerformanceTireInfo).speedRating > 100'
  QueryKeyExpression clonedExpression = new TreatAsExpression(castClass, this);
  clonedExpression.shouldQueryToManyRelationship = this.shouldQueryToManyRelationship;
  //using shouldUseOuterJoin to indicate the join to use between the t and PerformanceTireInfo subclass.  
  clonedExpression.hasQueryKey = this.hasQueryKey;
  clonedExpression.hasMapping = this.hasMapping;
  this.addDerivedExpression(clonedExpression);
  return clonedExpression;
}

相关文章

微信公众号

最新文章

更多

QueryKeyExpression类方法