EJBQL 中 Seam 限制的使用
我对 Seam 很陌生,我需要在下面的代码中进行一些澄清,我需要知道它是如何工作的,在这段代码中 RESTRICTIONS 有什么用......
package org.domain.pixel.action;
import org.domain.pixel.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;
@Name("projectList")
public class ProjectList extends EntityQuery<Project> {
private static final long serialVersionUID = -7673337640345325071L;
private static final String EJBQL = "select project from Project project";
private static final String[] RESTRICTIONS = {
"lower(project.processOwner) like lower(concat(#{projectList.project.processOwner},'%'))",
"lower(project.projectName) like lower(concat(#{projectList.project.projectName},'%'))",
};
private Project project = new Project();
public ProjectList() {
;
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(25);
}
public Project getProject() {
return project;
}
}
I am very new to Seam, I need some clarification in this below code , I need to know how it works, what is use of RESTRICTIONS in this code .......
package org.domain.pixel.action;
import org.domain.pixel.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;
@Name("projectList")
public class ProjectList extends EntityQuery<Project> {
private static final long serialVersionUID = -7673337640345325071L;
private static final String EJBQL = "select project from Project project";
private static final String[] RESTRICTIONS = {
"lower(project.processOwner) like lower(concat(#{projectList.project.processOwner},'%'))",
"lower(project.projectName) like lower(concat(#{projectList.project.projectName},'%'))",
};
private Project project = new Project();
public ProjectList() {
;
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(25);
}
public Project getProject() {
return project;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您发布的代码是Seam 中为基于列表的视图创建支持bean(或“操作”)的标准方法。
ProjectList
基于 JPA 查询(称为“EJBQL”)创建一个结果集,并且限制是为此查询动态创建 WHERE 子句的一种方法,例如基于用户输入。用户输入很可能放置在名为“
project
”的实例变量中。限制(总共 2 个)仅选择processOwner
和projectName
等于processOwner 的记录(来自与 Project 实体类对应的表)
以及“project
”中设置的projectName
(基于不区分大小写的比较)。The code you posted is a standard approach in Seam to create a backing bean (or "action") for views that are list-based. The
ProjectList
creates a result set based on the JPA query (called "EJBQL"), and the restrictions are a a means to dynamically create a WHERE clause for this query, for instance based on user input.The user input is most likely placed in the instance var called "
project
". The restrictions (2 in total) select only records (from the table corresponding to the Project entity class) for which theprocessOwner
AND theprojectName
are equal to theprocessOwner
AND theprojectName
set in "project
" (based on a case-insensitive comparison).