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 ...