1 Reply Latest reply on Jan 31, 2008 11:04 AM by Caedmon Judd

    Problem with EntityQuery, Design Question about it

    Chr D Newbie


      I used Seam-gen to create a CRUD Application out of my database.
      Works fine so far, but i now i, of course, need to customize it for my needs.

      I need to run a query and i think i should use the package com.ccms30.entities;

      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.framework.EntityQuery;
      import java.util.List;
      import java.util.Arrays;

      public class CcmsProductlineList extends EntityQuery {
       private static final long serialVersionUID = 1L;
       private static final String[] RESTRICTIONS = {
       "lower(ccmsProductline.name) like concat(lower(#{ccmsProductlineList.ccmsProductline.name}),'%')",
       "lower(ccmsProductline.description) like concat(lower(#{ccmsProductlineList.ccmsProductline.description}),'%')",};
       private CcmsProductline ccmsProductline = new CcmsProductline();
       public String getEjbql() {
       return "select ccmsProductline from CcmsProductline ccmsProductline";
       public Integer getMaxResults() {
       return 25;
       public CcmsProductline getCcmsProductline() {
       return ccmsProductline;
       public List<String> getRestrictions() {
       return Arrays.asList(RESTRICTIONS);

      this Class for it.

      So here are my questions:

      - How should i run a query on an attribute? just, for example, set the name in object ccmsProductline and then run getResultList? or should i write an own class? how to design my own querys, which are nothing else than a list so far?

      - Why can i just use this class if I inject it into my the Bean i call it from?
      I cant create CcmsProductline ccmsProductline = new CcmsProductline(); and then use it... why? Would make things much more easy.

      Thanks a lot.