5 Replies Latest reply on Aug 4, 2010 5:42 AM by Haris Jan

    join two tables

    maggi maggi Newbie

      I have a select query joining two tables, Customer and Address. I have used seam-gen to generate entities. Now I need to display the result of this query. How should I right action class so that I can get the result? I am new bee to seam and EJB. Not sure of this. please help

        • 1. Re: join two tables
          Haris Jan Newbie

          i have the same problem i want to get the result of the foreign key table as well as the primary key table and display them through a join in the view i have no clue how to do that i have used @oneToMany etc but nothing seems to work rite !!!

          • 2. Re: join two tables
            maggi maggi Newbie

            You know what...seam is not flexible at all and it is useless to use seam unless you know all related technologies such as rich faces etc. As I progressed I relalised after a month to leave seam and prefer a framework and jsp.


            Sorry I could not help.

            • 3. Re: join two tables
              Sean Tozer Newbie

              What you two are trying to do is really very simple, and is actually something that Seam and Hibernate supports with very minimal effort. Seam certainly has areas in which I wish it was more flexible, but I don't think you'd be running into one on this. You certainly do need to figure out how to use the associated packages to use Seam, such as Richfaces and Hibernate, but that's really the case for any framework. It doesn't make sense to learn the framework without learning the rendering package or the orm package.


              As for what you're trying to do, it should be pretty straighforward. Don't think of it as trying to display something through a join in the view. That doesn't really make a lot of sense in this context. Instead, try to think of how the ORM (object relational mapping) works.


              As in the original question, say you had a customer with some number of addresses. Within the Customer entity, then, you would have a Set<Address> field with a getAddresses() accessor. If you wanted to display all the addresses for a customer, it'd be a simple matter of passing that set to a rich:dataTable and then setting up some columns to display whatever information it is that you wanted.


              If instead you wanted to display, say, a number of customers and all of their associated addresses, your best bet would probably be a rich:subtable. Just use a datatable to iterate over your customers, and then within each customer record, use a subtable to iterate over that customer's addresses.

              • 4. Re: join two tables
                Haris Jan Newbie

                in the data base i have a table user to whom tasks are assigned from another table tasks with a table linking them that is task status , and another table taskcomment where comments are given on a task id by the respective user id's , the foreign keys of task id are in the table taskcomment against a user. i want to use joins to get the results of tasks assigned to the person who is signed in and the tasks that he has assigned and also the corresponding comments on those tasks
                in the postgres db i have made relationships but i dont know how to incorporate them here in seam i've read books etc to use the annotations @manyToOne and @onetomany i need your help with the aid of an example to understand this procedure i have an sql query which i have checked in the data Base


                as i'm totally new to seam i definitely require your help
                Thank You !


                 

                • 5. Re: join two tables
                  Haris Jan Newbie

                  i got the joins and i get the result for the  the query
                  SELECT t FROM TblTask t RIGHT JOIN t.comments tc

                  but i cant seem to get the result set  for the query
                  SELECT t FROM TblTask t RIGHT JOIN t.comments tc

                  the default List.jsp shows the error for inpt primary key  and gives a conversion error
                  but i think that it dosent understand how to handle the rsult of tow objects from to different tables
                  kindly help me in this regard
                  THANK YOU !