6 Replies Latest reply on May 22, 2007 4:32 PM by hstang

    Complete, working Example-Implementation for EntityHome<Obje

    mugwump

      After struggling a while with getting an implementation for EntityHome running, I am about to give up: A comlete example, that is actually running and can be deployed, would be helpful - the docs are too sparse to get this things really up and running: Here is my problem:

      Given the example from the docs:

      @Stateful
      @Name("personHome")
      public class PersonHome extends EntityHome<Person> implements LocalPersonHome {
      


      The docs say:
      A second advantage is that your classes may be EJB stateful sessin beans, if you like. (They do not have to be, they can be plain JavaBean components if you prefer.)


      However, if I don't make the PersonHome either stateful or a stateless SessionBean, I get JTA-Transaction-Excpetions. But if I make them Stateful, I have to figure out which methods are needed on the Interface, as all Classes above (EntityHome and Home) are abstract and don't have any interface I could simply extend.

      Overall, this approach looks only half-finished (lacking proper documentation, examples and refactoring) - which is really a shame, as it is not flagged "experimental" and naive users like me are tempted to give it a try (although I should know it better by now and wait for at least two iterations for the api to stabilize...)

      If anyone has gotten this baby to run, I would really appreciate any hints/examples!!

      cheers
      stf

      PS: Please don't misunderstand this post, I absolutely love seam, but it would be really helpful to flag new and untested parts of the framework accordingly instead of mixing them with the stable ones....




        • 1. Re: Complete, working Example-Implementation for EntityHome<
          gavin.king

          Currently there is a bug in JBoss EJB3 which meant that it was hard to write a Home object using EJB3. This is probably already fixed.

          So follow the contactlist example (which does not use EJB3) to see how to use plain JavaBean components, or just let seam-gen generate everything for you.

          • 2. Re: Complete, working Example-Implementation for EntityHome<
            mugwump

            Ok, the contactlist provides an example for the declarative use of the class via fwk in the components.xml - is it actually possible right now to use plain javabeans for the implementation (with not only the managed part being javabeans, but also the controller e.g. ContactHome is implemented as a POJO)?!

            And even if it is possible: If we want to write a ContactHome as a Stateless/Stateful SessionBean, the LocalContactHome still needs all the methods like getInstance, setId etc. on it's interface: An interface with all the methods, which are now only on the abstract classes, would still come in handy for that case....

            • 3. Re: Complete, working Example-Implementation for EntityHome<
              gavin.king

              Try out "seam generate-entities".

              • 4. Re: Complete, working Example-Implementation for EntityHome<
                purplahaze

                I can't use "seam generate-entities"
                our DB has about 3000 tables and views.
                (with views in Sybase 'seam generate-entities' don't work properly)
                It would be nice make this call
                seam generate-entities <table1 table2 table3>

                I have to use StoredProcedures.
                To call it, I make injection
                @Resource(mappedName="java:/web_franceDatasource")
                DataSource ds;

                ....
                Connection conn = ds.getConnection();
                CallableStatement cs = conn.prepareCall(sql);

                but with POJOs it didn't work :(

                • 5. Re: Complete, working Example-Implementation for EntityHome<
                  anarinsky

                  Dear Gaven,

                  Seam-gen allows one to quickly generate a lot of functionalities. However, EntityHome objects are used instead of session beans.

                  The only available example for using EntityHome objects is seampay, but this example is not described in the documentation or available books.

                  Adding documentation/examples for using seam-gen and EntityHome would be very useful.

                  Do you plan to do this?
                  Thanks!

                  • 6. Re: Complete, working Example-Implementation for EntityHome<

                    dvdstore, contactlist, and ui also use EntityHome declaritively in components.xml.