From: | "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de> |
---|---|
To: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | "reverse engineering" tool ? |
Date: | 2010-03-26 14:32:53 |
Message-ID: | C4DAC901169B624F933534A26ED7DF31034BB566@JENMAIL01.ad.intershop.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 ...
From | Date | Subject | |
---|---|---|---|
Next Message | Sriram P | 2010-03-27 08:19:12 | org.postgresql.util.PSQLException: ERROR: relation "dual" does not exist Position: 42 |
Previous Message | John Abraham | 2010-03-26 14:05:24 | Re: GUC variables in parameter URL |