5 Replies Latest reply on Jun 28, 2007 12:56 AM by alexrozario

    Retrieving data from database

    alexrozario

      Hi all,

      I have created an entity bean class as Stores.java and Stateless Session bean as SearchSession.java.

      And i am using Search.xhtml(facelet) file to retrieve data from table Stores in my local database.

      I am using Seam 1.2.1 GA version to configure them

      and i am using a query as
      List details =em.createQuery("select s from Stores s").getResultList(); in my Session bean.

      and i am using datatable in my .xhtml file to view the data.
      but it doesn't shows any result. my table has more than 5 records. whats wrong in my coding. how to overcome this..

      please help me..

      thanks in advance..

      i am waiting for your valueable help

        • 1. Re: Retrieving data from database
          kruno

          Please post the source.

          • 2. Re: Retrieving data from database
            alexrozario

            hi kruno,

            thank you for your response..
            i found that its not an database error.
            i can retrieve data from table..

            but the problem is in viewing..
            how to view(display) that details in my view page..

            i am using facelet file to view that data.

            and this is my session bean class which retrieving data

            @Stateless
            @Name("searchsession")
            public class SearchSession implements SearchLocal
            {
            @Out
            private List details;

            public String search()
            {
            details =em.createQuery("select s.storeName,s.reviewPoints,s.website from Stores s").getResultList();
            System.out.println("list : "+details);
            return "query";
            }
            }

            and my facelet file contains,

            <rich:dataTable width="483" id="details" rows="10" columnClasses="col" value="#{details}" var="val">
            <h:column>
            <h:outputText value="#{val.storeName}" />
            </h:column>
            <h:column>
            <h:outputText value="#{val.reviewpoints}" />
            </h:column>
            <h:column>
            <h:outputText value="#{val.website}" />
            </h:column>
            </rich:dataTable>

            now help me to view them in my facelet file..
            thank you

            • 3. Re: Retrieving data from database
              kruno

              Select seems to be the problem em.createQuery("select s.storeName,s.reviewPoints,s.website from Stores s").getResultList();

              this way you will get String [] in side private List details;
              you need to get list of object Stores,
              try this: em.createQuery("from Stores s").getResultList();

              • 4. Re: Retrieving data from database
                alexrozario

                 

                "alexrozario" wrote:

                how to view(display) that details in my view page..

                i am using facelet file to view that data.

                and this is my session bean class which retrieving data

                @Stateless
                @Name("searchsession")
                public class SearchSession implements SearchLocal
                {
                 @Out
                 private List details;
                
                 public String search()
                 {
                 details =em.createQuery("select s.storeName,s.reviewPoints,s.website from Stores s").getResultList();
                 System.out.println("list : "+details);
                 return "query";
                 }
                }
                

                and my facelet file contains,

                <rich:dataTable width="483" id="details" rows="10" columnClasses="col" value="#{details}" var="val">
                 <h:column>
                 <h:outputText value="#{val.storeName}" />
                 </h:column>
                 <h:column>
                 <h:outputText value="#{val.reviewpoints}" />
                 </h:column>
                 <h:column>
                 <h:outputText value="#{val.website}" />
                 </h:column>
                </rich:dataTable>
                

                now help me to view them in my facelet file..
                thank you


                • 5. Re: Retrieving data from database
                  alexrozario

                  i am trying your suggestion too kruno..
                  but cant finish it off. still i am facing the same issue.

                  help me to overcome this issue