"reverse engineering" tool ? - Mailing list pgsql-jdbc

From Marc Mamin
Subject "reverse engineering" tool ?
Date
Msg-id C4DAC901169B624F933534A26ED7DF31034BB566@JENMAIL01.ad.intershop.net
Whole thread Raw
List pgsql-jdbc

Hello,

before I start to write a dirty function to speed up our development, I'd like to check if anybody already has such a tool...

We don't use any modelling  tool to extend our database model, but sometimes we need to write an equivalent java class for some table. Also something like the opposite of pbeans (http://pbeans.sourceforge.net/).

My idea is to write a simple procedure that generate a "start with"  template as plain text  using pg_catalog to get the table definition.

the output could be something like that :

public class tableName
{
   
    PreparedStatement stmt = null;
    Connection conn = null;
   
    String  <column1>;
    boolean <column2>;
    int     <column3>;
    ...
   
    public tableName (<javaType> Integer.parseInt( uid), Connection conn)
    {
        this.conn = conn;
       
        try
        {
            stmt = conn.prepareStatement("select * from <tablename> where <primary key> = ?");
            stmt.set<Type>(1, Integer.parseInt( uid));
           
            ResultSet rs = stmt.executeQuery();
   
            if (! rs.next())
            {
                throw new someException...("Not Found !");
            }
            else
            {
           
               this.<column1> = rs.get...;
               this.<column2> = rs.get...;
               this.<column3> = rs.get...;
           ....       
           
            }
            rs.close();
        }
        catch(SQLException e)
        {
            throw new someException("...",e);
        }
    }
   
   
   
    + autogenerated methods to get / update the table fields ...
   
   
   



pgsql-jdbc by date:

Previous
From: John Abraham
Date:
Subject: Re: GUC variables in parameter URL
Next
From: Sriram P
Date:
Subject: org.postgresql.util.PSQLException: ERROR: relation "dual" does not exist Position: 42