2 Replies Latest reply on Oct 20, 2008 5:20 PM by Andy Gibson

    When to use EntityQuery

    S T Newbie

      Hi all,


      after I read several books I have a question regarding Entity(Query/Home)...
      In most books you see Session Beans which are NOT subclasses from Seams' EntityQuery or EntityHome class.
      Also in the online seam reference the most examples are implemented by using the EntityManager directly...
      So my question is: When do I use the Entity(*) classes?


      Bests,
      Sushi

        • 1. Re: When to use EntityQuery
          Andy Gibson Novice

          I use them pretty much all the time.


          The documentation and the examples were written mainly before the entity() classes came about.

          If you look at a Seam Gen'd app with generated classes and so on, they use the entity(
          ) pretty exclusively.


          I use them for holding CRUD entities or entity result sets. If I need a static list, say a list of lookup values, I would use a regular bean and an entity manager. If I'm looking up entities based on an id and I need to perform CRUD on it, I'll use an EntityHome. If I need a list of entities (say a list of support issues for a project, or a set of search results) I'll use the entity query. Not only can I query using EL, but it also gives me the ability to paginate and order easily.


          Cheers,


          Andy

          • 2. Re: When to use EntityQuery
            Andy Gibson Novice

            Gah, that'll teach me to preview before I post.


            entity() = entity(*)


            Cheers,


            Andy