1 Reply Latest reply on Sep 19, 2010 3:37 AM by batorgil.kh.batorgil.yahoo.com

    EQL problem

    batorgil.kh.batorgil.yahoo.com
      Hi Guys...

      I've a problem that is on seam EQLanguage...I'm developing seam web app.
      I trying to by choosing article from section and category which are entity bean..


      Article bean
      `@Entity
      @Table(name = "article", catalog = "techportal")
      public class Article implements java.io.Serializable {

           private Integer id;
           private User userByEditorId;
           private User userByAuthorId;
           private Section section;
           private Category category;
           private String title;
           private String intro;
           private String content;
           private String state;
           private Date created;
           private Date modfied;
           private Date published;
           private Integer hitcount;
           private Set<Comment> comments = new HashSet<Comment>(0);
           private String coverpic;

           public Article() {
           }
      `

      Section bean


      `
      @Entity
      @Table(name = "section", catalog = "techportal")
      public class Section implements java.io.Serializable {

           private Integer id;
           private String name;
           private Set<Article> articles = new HashSet<Article>(0);
           private Set<Category> categories = new HashSet<Category>(0);

           public Section() {
           }

           public Section(String name) {
                this.name = name;
           }

           public Section(String name, Set<Article> articles,
                     Set<Category> categories) {
                this.name = name;
                this.articles = articles;
                this.categories = categories;
           }

      `

      Category bean


      `@Entity
      @Table(name = "category", catalog = "techportal")
      public class Category implements java.io.Serializable {

           private Integer id;
           private Section section;
           private String name;
           private Set<Article> articles = new HashSet<Article>(0);

           public Category() {
           }

           public Category(Section section, String name) {
                this.section = section;
                this.name = name;
           }

           public Category(Section section, String name, Set<Article> articles) {
                this.section = section;
                this.name = name;
                this.articles = articles;
           }
      `

      hierarchy is  :
      section -> category -> Article.

      Category : new product , game , advice
      I tried to filtering articles from new product category.





        • 1. Re: EQL problem
          batorgil.kh.batorgil.yahoo.com

          this is my implement codes:


          @Name("homeNewProduct")          
          public class HomeNewProduct extends EntityQuery<Article>  {
               
               private static final String homeProduct = "select article from Article article ORDER BY created desc where category.id = '17' ";
               private Article article = new Article();
               
               public Article getArticle() {
                    return article;
               }
              public HomeNewProduct() {
                   setEjbql(homeProduct);
                    setMaxResults(1);
                    
                   
              }
          



          home.xhtml page



          <h:panelGrid columns="2" cellpadding="2">
                                   <ui:repeat id="NewProduct" value="#{homeNewProduct.resultList}" var="_homeProduct">
                                        <div class="home-newProduct">
                                        <div class="home-newProduct-title">
                                        <s:link value="#{_homeProduct.title}" view="/medee.xhtml">
                                             
                                         <f:param id="productID" name="id" value="#{_homeProduct.id}" />
                                        </s:link>
                                        </div>
          
                                        <div class="home-newProduct-date">
                                        <p><span class="new">#{_homeProduct.created}</span></p>
                                        </div>
          
                                        <div class="home-newProduct-text">
          
          
                                        <div class="home-newProduct-pic">
                                        <h:graphicImage
                                             value="img/noimage.gif" rendered="#{empty _homeProduct.coverpic}" />
                                        <h:graphicImage value="#{_homeProduct.coverpic}"
                                             rendered="#{not empty _homeProduct.coverpic}" width="90"
                                             height="90" /></div>
                                        <div class="home-newProduct-texttt">
                                        <div style="text-align: justify;">#{_homeProduct.intro}</div>
                                        </div>
                                        </div>
                                        </div>
                                   </ui:repeat>
                              </h:panelGrid>
          




          ????????