cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Sösemann <>
Subject eliminate duplicate data in beans
Date Thu, 12 Dec 2002 20:18:55 GMT

I have the feeling, that what I am doing can be done more elegant without
hardcoding db schema information into a java bean.

I am using java beans to transport data through the different steps of a CMS
(inside a session).

Users are a adding data in every step to a bean representing a db relation.
When the wizard is completed the bean knows how to write to the db.

That's how a bean looks like:

class ArticleBean {

    private String user;
    private String text;

  public void setUser(String val) {..}
  public void setText(String val) {..}

 ...   public void saveToDb() throws SQLException {
            Statement st = conn.createStatement();
            st.execute("INSERT INTO article (user, text, pic, abstract,
            ResultSet res = st.getGeneratedKeys();
   = res.getInt("id");
        } ...

As this is a java bean, I actually don't need to tell the query that it
should do this with table "article" and how its attributes are. This
information is allready in the setter- getter methods and so on.

The best would be to generate such beans from the dbs schema information
only. Is there a way to make this more efficient and without duplicate

Thanks in advance.


Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message