EJBQL 中 Seam 限制的使用

发布于 2024-09-07 00:28:38 字数 990 浏览 4 评论 0原文

我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你的星星会说话 2024-09-14 00:28:38

您发布的代码是Seam 中为基于列表的视图创建支持bean(或“操作”)的标准方法。 ProjectList 基于 JPA 查询(称为“EJBQL”)创建一个结果集,并且限制是为此查询动态创建 WHERE 子句的一种方法,例如基于用户输入。

用户输入很可能放置在名为“project”的实例变量中。限制(总共 2 个)仅选择 processOwnerprojectName 等于 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 the processOwner AND the projectName are equal to the processOwner AND the projectName set in "project" (based on a case-insensitive comparison).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文