cocoon-users mailing list archives

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

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,
keyword')",
                Statement.RETURN_GENERATED_KEYS);
....
            ResultSet res = st.getGeneratedKeys();
            res.first();
            this.id = 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
information.

Thanks in advance.

Rob



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message