6 Replies Latest reply on Mar 25, 2008 2:55 PM by Robert Diaz

    Newb database help

    Robert Diaz Newbie

      Hi all.

      I've been trying to figure out how to use seam for a few days now, and the one thing that I can't seem to get is the database interactions. I've looked through the tutorials, but they are slightly cryptic as to how to access the database with just a function call. This may not be the way to do things in seam, but this is how I'm used to doing it (I've been using JSF and J2EE).

      Am I completely missing something or do I need to use something different?


        • 1. Re: Newb database help
          Volker Reichel Newbie

          Hi Robert,

          I'm not sure I got your message right. Especially I do not understand what you mean with ...access the database with just a function call. So I will give you a typical seam scenario:
          In Seam there are POJOs or entities which can be stored or retrieved from a database using either Hibernate or any other JPA framework. There is no need for a seam developer to use database connections and/or statements/prepared statements. All you have to do is specify (by annotations) which fields of a pojo or entity should be persistet. The runtime java object is linked to database rows/columns via an EntityManager or PersistenceContext. You only need to declare such a manager/context in your java code and provide a persistence unit (persistence.xml) and a datasource definition.

          Hope this helps to understand how seam works.

          • 2. Re: Newb database help
            Robert Diaz Newbie

            That does help a bit. Although I'm still a bit lost on how to insert information into the database using entities. Is that a Hibernate thing or is there some special way of doing it? I'm used to using prepared statements like you said, so I have no idea what to do here.


            • 3. Re: Newb database help

              how about reading the seam reference, or studying the examples in your seam installations examples directory?

              • 4. Re: Newb database help
                Robert Diaz Newbie

                I have been reading the reference and looking at the examples. My problem is that I'm needing to insert information into multiple tables in the DB at the same time from one page and all of the examples only deal with one table at a time from one page. Is there some way around this or did I just miss something?

                • 5. Re: Newb database help

                  do you mean smth. like this?

                  public class Manager {
                    EntityA entityA = new EntityA();
                    EntityB entityB = new EntityB();
                    //getter/setter for entities
                    public String persist() {
                     return "persisted";

                  • 6. Re: Newb database help
                    Robert Diaz Newbie

                    Yeah. That was what I was talking about. Thanks.