4 Replies Latest reply on Nov 4, 2005 6:20 AM by epbernard

    How do I do mapping for a view?

      I have a view comprised of a couple of tables.

      How do I use it in EJB3? I cannot make it a regular par, since it isn't a plain old table.

      Any examples would be nice!

        • 1. Re: How do I do mapping for a view?

          Here is an example of a view with 5 tables. How would I represent this using par/ejb3?

          CREATE VIEW myView AS
          select a.One, a.Two, a.Three, a.Four, a.Five, a.Six, d.Seven, c.Eight, b.Nine, a.Ten
          from (TableA a join (TableB b join (TableC c join (TableD d join TableE e))))
          where ((a.One = e.One)
          and (e.One = 1)
          and (c.Eight = a.Nine)
          and (d.Two = c.Two)
          and (a.Three = d.Three))
          


          • 2. Re: How do I do mapping for a view?

            I have tried making a par

            @Entity
            @Table(name = "myView")
            public final class MyTestPar {
             int One;
             String Two;
             String Three;
             String Four;
             String Five;
             String Six;
             String Seven;
             String Eight;
             String Nine;
             String Ten;
            
            //I made generic get and sets for each variable shown above
            }
            


            Now when I do this
             return em.createQuery("from MyTestPar p ");
            


            I get no results. However If I look in the database, my view contains 5 rows.

            • 3. Re: How do I do mapping for a view?

              anyone?

              • 4. Re: How do I do mapping for a view?
                epbernard

                this is supposed to work as expected. Be sure to disable the hbmddl feature though by setting none