4 Replies Latest reply on Nov 13, 2008 3:04 PM by Stefano Travelli

    Problem with Seam, Database and Question

    Remigius Kwiatkowski Newbie
      Ich habe ein Problem mit der Abfrage einer zweiten Tabelle über die erste. Und zwa es sind zwei Tabellen

      user       mit   userid        username     password   email
      friends    mit   friendsid     userid


      jetzt will ich über die userid in der Tabelle friends die username, email aus der Tabelle user in erfahrung bringen und in xhtml anzeigen lassen.

      Momentan bekomme ich diese Fehlermeldung  : Error reading 'resultList' on type org.domain.Projekt3.entity.FriendsList_$$_javassist_39



      die SQL abfrage mache ich im Friendslist.Code mit :            

              @Override
              public String getEjbql() {
              return "SELECT username FROM user INNER JOIN friends ON (friends.userid=user.userid)";
              }




             
      Die fast kompletten Quelltexte:




      FriendsList.java


      package org.domain.Projekt3.entity;

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

      @Name("friendsList")
      public class FriendsList extends EntityQuery {

              private static final String[] RESTRICTIONS = {};

              private Friends friends = new Friends();
      /*
              @Override
              public String getEjbql() {
                      return "select friends from Friends friends";
              }
              */
             
              @Override
              public String getEjbql() {
                      return "SELECT username FROM user INNER JOIN friends ON (friends.userid=user.userid)";
              }
             
             
             
             
             
             
             

              @Override
              public Integer getMaxResults() {
                      return 25;
              }

              public Friends getFriends() {
                      return friends;
              }

              @Override
              public List<String> getRestrictions() {
                      return Arrays.asList(RESTRICTIONS);
              }

      }








      FriendsList.xhtml


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                      template="layout/template.xhtml">
                            
      <ui:define name="body">
         
          <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
         
        <!--  
          <h:form id="friendsSearch" styleClass="edit">
         
              <rich:simpleTogglePanel label="Friends search parameters" switchType="ajax">
             
             
              </rich:simpleTogglePanel>
             
              <div class="actionButtons">
                  <h:commandButton id="search" value="Search" action="/FriendsList.xhtml"/>
              </div>
             
          </h:form>
         
          <rich:panel>
              <f:facet name="header">Friends search results</f:facet>
          <div class="results" id="friendsList">

          <h:outputText value="No friends exists"
                     rendered="#{empty friendsList.resultList}"/>
                    
          <rich:dataTable id="friendsList"
                      var="friends"
                    value="#{friendsList.resultList}"
                 rendered="#{not empty friendsList.resultList}">
              <h:column>
                  <f:facet name="header">
                      <s:link styleClass="columnHeader"
                                   value="friendid #{friendsList.order=='friendid asc' ? messages.down : ( friendsList.order=='friendid desc' ? messages.up : '' )}">
                          <f:param name="order" value="#{friendsList.order=='friendid asc' ? 'friendid desc' : 'friendid asc'}"/>
                      </s:link>
                  </f:facet>
                  #{friends.friendid}
              </h:column>
             
             
             
             
              <h:column>
                  <f:facet name="header">
                      <s:link styleClass="columnHeader"
                                   value="userid #{friendsList.order=='userid asc' ? messages.down : ( friendsList.order=='userid desc' ? messages.up : '' )}">
                          <f:param name="order" value="#{friendsList.order=='userid asc' ? 'userid desc' : 'userid asc'}"/>
                      </s:link>
                  </f:facet>
                  #{friends.userid}
              </h:column>
             
             
      -->      
            
               <h:column>
                  <f:facet name="header">
                      <s:link styleClass="columnHeader"
                                   value="username #{userList.order=='username asc' ? messages.down : ( userList.order=='username desc' ? messages.up : '' )}">
                          <f:param name="order" value="#{userList.order=='username asc' ? 'username desc' : 'username asc'}"/>
                      </s:link>
                  </f:facet>
                  #{user.username}
              </h:column>
          
           

             
             
             
        <!--      
             
              <h:column>
                  <f:facet name="header">action</f:facet>
                  <s:link view="/#{empty from ? 'Friends' : from}.xhtml"
                         value="Select"
                            id="friends">
                      <f:param name="friendsFriendid"
                              value="#{friends.friendid}"/>
                  </s:link>
              </h:column>
          </rich:dataTable>

          </div>
          </rich:panel>
         
          <div class="tableControl">
           
              <s:link view="/FriendsList.xhtml"
                  rendered="#{friendsList.previousExists}"
                     value="#{messages.left}#{messages.left} First Page"
                        id="firstPage">
                <f:param name="firstResult" value="0"/>
              </s:link>
             
              <s:link view="/FriendsList.xhtml"
                  rendered="#{friendsList.previousExists}"
                     value="#{messages.left} Previous Page"
                        id="previousPage">
                  <f:param name="firstResult"
                          value="#{friendsList.previousFirstResult}"/>
              </s:link>
             
              <s:link view="/FriendsList.xhtml"
                  rendered="#{friendsList.nextExists}"
                     value="Next Page #{messages.right}"
                        id="nextPage">
                  <f:param name="firstResult"
                          value="#{friendsList.nextFirstResult}"/>
              </s:link>
             
              <s:link view="/FriendsList.xhtml"
                  rendered="#{friendsList.nextExists}"
                     value="Last Page #{messages.right}#{messages.right}"
                        id="lastPage">
                  <f:param name="firstResult"
                          value="#{friendsList.lastFirstResult}"/>
              </s:link>
             
          </div>
         
          <s:div styleClass="actionButtons" rendered="#{empty from}">
              <s:button view="/FriendsEdit.xhtml"
                          id="create"
                       value="Create friends">
                  <f:param name="friendsFriendid"/>
              </s:button>
          </s:div>
         
         
      -->   
         
         
      </ui:define>

      </ui:composition>






        • 1. Re: Problem with Seam, Database and Question
          Matt Nirgue Newbie

          huh?


          I think you'd have a better chance to get an answer if you explain your problem in english... or maybe I'm the only one who doesn't understand german :/


          • 2. Re: Problem with Seam, Database and Question
            Ronald van Kuijk Apprentice

            Well... you are ;-) It's clear to me (not that I know the solution) and even Google understands it :-P

            • 3. Re: Problem with Seam, Database and Question
              Remigius Kwiatkowski Newbie
              <blockquote>
              _Remigius Kwiatkowski wrote on Nov 12, 2008 17:06:_<br/>

              Ich habe ein Problem mit der Abfrage einer zweiten Tabelle über die erste. Und zwa es sind zwei Tabellen

              user       mit   userid        username     password   email
              friends    mit   friendsid     userid


              jetzt will ich über die userid in der Tabelle friends die username, email aus der Tabelle user in erfahrung bringen und in xhtml anzeigen lassen.

              Momentan bekomme ich diese Fehlermeldung  : Error reading 'resultList' on type org.domain.Projekt3.entity.FriendsList_$$_javassist_39



              die SQL abfrage mache ich im Friendslist.Code mit :            

                      @Override
                      public String getEjbql() {
                      return "SELECT username FROM user INNER JOIN friends ON (friends.userid=user.userid)";
                      }




                     
              Die fast kompletten Quelltexte:




              FriendsList.java


              package org.domain.Projekt3.entity;

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

              @Name("friendsList")
              public class FriendsList extends EntityQuery {

                      private static final String[] RESTRICTIONS = {};

                      private Friends friends = new Friends();
              /*
                      @Override
                      public String getEjbql() {
                              return "select friends from Friends friends";
                      }
                      */
                     
                      @Override
                      public String getEjbql() {
                              return "SELECT username FROM user INNER JOIN friends ON (friends.userid=user.userid)";
                      }
                     
                     
                     
                     
                     
                     
                     

                      @Override
                      public Integer getMaxResults() {
                              return 25;
                      }

                      public Friends getFriends() {
                              return friends;
                      }

                      @Override
                      public List<String> getRestrictions() {
                              return Arrays.asList(RESTRICTIONS);
                      }

              }








              FriendsList.xhtml


              <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                                           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                              xmlns:s="http://jboss.com/products/seam/taglib"
                              xmlns:ui="http://java.sun.com/jsf/facelets"
                              xmlns:f="http://java.sun.com/jsf/core"
                              xmlns:h="http://java.sun.com/jsf/html"
                              xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                              template="layout/template.xhtml">
                                    
              <ui:define name="body">
                 
                  <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
                 
                <!--  
                  <h:form id="friendsSearch" styleClass="edit">
                 
                      <rich:simpleTogglePanel label="Friends search parameters" switchType="ajax">
                     
                     
                      </rich:simpleTogglePanel>
                     
                      <div class="actionButtons">
                          <h:commandButton id="search" value="Search" action="/FriendsList.xhtml"/>
                      </div>
                     
                  </h:form>
                 
                  <rich:panel>
                      <f:facet name="header">Friends search results</f:facet>
                  <div class="results" id="friendsList">

                  <h:outputText value="No friends exists"
                             rendered="#{empty friendsList.resultList}"/>
                            
                  <rich:dataTable id="friendsList"
                              var="friends"
                            value="#{friendsList.resultList}"
                         rendered="#{not empty friendsList.resultList}">
                      <h:column>
                          <f:facet name="header">
                              <s:link styleClass="columnHeader"
                                           value="friendid #{friendsList.order=='friendid asc' ? messages.down : ( friendsList.order=='friendid desc' ? messages.up : '' )}">
                                  <f:param name="order" value="#{friendsList.order=='friendid asc' ? 'friendid desc' : 'friendid asc'}"/>
                              </s:link>
                          </f:facet>
                          #{friends.friendid}
                      </h:column>
                     
                     
                     
                     
                      <h:column>
                          <f:facet name="header">
                              <s:link styleClass="columnHeader"
                                           value="userid #{friendsList.order=='userid asc' ? messages.down : ( friendsList.order=='userid desc' ? messages.up : '' )}">
                                  <f:param name="order" value="#{friendsList.order=='userid asc' ? 'userid desc' : 'userid asc'}"/>
                              </s:link>
                          </f:facet>
                          #{friends.userid}
                      </h:column>
                     
                     
              -->      
                    
                       <h:column>
                          <f:facet name="header">
                              <s:link styleClass="columnHeader"
                                           value="username #{userList.order=='username asc' ? messages.down : ( userList.order=='username desc' ? messages.up : '' )}">
                                  <f:param name="order" value="#{userList.order=='username asc' ? 'username desc' : 'username asc'}"/>
                              </s:link>
                          </f:facet>
                          #{user.username}
                      </h:column>
                  
                   

                     
                     
                     
                <!--      
                     
                      <h:column>
                          <f:facet name="header">action</f:facet>
                          <s:link view="/#{empty from ? 'Friends' : from}.xhtml"
                                 value="Select"
                                    id="friends">
                              <f:param name="friendsFriendid"
                                      value="#{friends.friendid}"/>
                          </s:link>
                      </h:column>
                  </rich:dataTable>

                  </div>
                  </rich:panel>
                 
                  <div class="tableControl">
                   
                      <s:link view="/FriendsList.xhtml"
                          rendered="#{friendsList.previousExists}"
                             value="#{messages.left}#{messages.left} First Page"
                                id="firstPage">
                        <f:param name="firstResult" value="0"/>
                      </s:link>
                     
                      <s:link view="/FriendsList.xhtml"
                          rendered="#{friendsList.previousExists}"
                             value="#{messages.left} Previous Page"
                                id="previousPage">
                          <f:param name="firstResult"
                                  value="#{friendsList.previousFirstResult}"/>
                      </s:link>
                     
                      <s:link view="/FriendsList.xhtml"
                          rendered="#{friendsList.nextExists}"
                             value="Next Page #{messages.right}"
                                id="nextPage">
                          <f:param name="firstResult"
                                  value="#{friendsList.nextFirstResult}"/>
                      </s:link>
                     
                      <s:link view="/FriendsList.xhtml"
                          rendered="#{friendsList.nextExists}"
                             value="Last Page #{messages.right}#{messages.right}"
                                id="lastPage">
                          <f:param name="firstResult"
                                  value="#{friendsList.lastFirstResult}"/>
                      </s:link>
                     
                  </div>
                 
                  <s:div styleClass="actionButtons" rendered="#{empty from}">
                      <s:button view="/FriendsEdit.xhtml"
                                  id="create"
                               value="Create friends">
                          <f:param name="friendsFriendid"/>
                      </s:button>
                  </s:div>
                 
                 
              -->   
                 
                 
              </ui:define>

              </ui:composition>





              In englisch:


              I have a problem with the query about a second table on the first. ZWA and there are two tables

              userid user with username password email
              friends with friendsid userid


              Now I want on the userid in the table friends the username, e-mail from the user table in experience and in xhtml display.

              At the moment I get this error message: Error reading 'resultList' on type org.domain.Projekt3.entity.FriendsList_$$_javassist_39


              the SQL query to do with the Friendslist.Code :

                      @Override
                      public String getEjbql() {
                      return "SELECT username FROM user INNER JOIN friends ON (friends.userid=user.userid)";
                      }





              Thanks for everyone




              • 4. Re: Problem with Seam, Database and Question
                Stefano Travelli Newbie

                This is not valid a valid EJBQL query:



                SELECT username FROM user INNER JOIN friends ON (friends.userid=user.userid)
                



                Later in you log you should see an SQLGrammar exception as the cause for Error reading 'resultList'.