开发者

Use Of Restriction in EJBQL for Seam

开发者 https://www.devze.com 2023-01-04 19:05 出处:网络
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 .......

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开发者_JS百科},'%'))",

   }; 

 private Project project = new Project();

 public ProjectList() {
  ;
  setEjbql(EJBQL);
  setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
  setMaxResults(25);
 }

 public Project getProject() {
  return project;
 }
}


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号