String query = "select 1+1 as my_sum,
now() as my_time, mollytestMgr.columns()
from mollytest";
PreparedStatement ps = con.prepareStatment(query);
ResultSet rs = ps.executeQuery();
List list = new ArrayList();
while (rs.next()) {
mollytest obj = mollytestMgr.getFromRS(rs);
obj.putExtraData("my_sum", rs.getInt("my_sum"));
obj.putExtraData("my_time", rs.getDate("my_time"));
}
//use the list later on...each mollytest object in the list will
//have the extra data..
*/
public void putExtraData(Object key, Object value)
{
synchronized (this) {
if (__extra_data == null) {
__extra_data = new HashMap();
}
}
__extra_data.put(key, value);
}
/**
Allows retrieving arbitrary object-specific data from this object.
This data should have been put via the {@link #putExtraData putExtraData}
method prior to invoking this method
*/
public Object getExtraData(Object key)
{
synchronized (this) {
if (__extra_data == null) {
return null;
}
}
return __extra_data.get(key);
}
public String toString()
{
final String nl = fc.io.IOUtil.LINE_SEP;
StringBuffer buf = new StringBuffer(256);
buf.append("Class Name: [mollytest]");
buf.append(" [isDiscarded=").append(this.isDiscarded()).append("]");
buf.append(" [isNew=").append(this.isNew()).append("]");
buf.append(" [isModified=").append(this.isModified()).append("]");
buf.append(nl);
buf.append("Note: IsNullInDB only meaningful for existing rows (i.e., isNew=false)");
buf.append(nl);
ByteArrayOutputStream out = new ByteArrayOutputStream(768);
TablePrinter.PrintConfig config = new TablePrinter.PrintConfig();
config.setPrintBorders(false);
config.setCellSpacing(1);
config.setCellPadding(0);
config.setAutoFit(true);
TablePrinter p = new TablePrinter(7, new PrintStream(out), config);
p.startTable();
p.startRow();
p.printCell("PK");
p.printCell("FK");
p.printCell("Field");
p.printCell("Value");
p.printCell("isModified");
p.printCell("isNullinDB");
p.printCell("isSerial/AutoInc");
p.endRow();
p.startRow();
p.printCell("x");
p.printCell("-");
p.printCell("uid");
p.printCell(String.valueOf(this.uid));
p.printCell((this.__isModified_uid) ?"x":"-");
p.printCell((this.__isNullInDB_uid) ?"x":"-");
p.printCell("x");
p.endRow();
p.startRow();
p.printCell("-");
p.printCell("-");
p.printCell("name");
p.printCell(String.valueOf(this.name));
p.printCell((this.__isModified_name) ?"x":"-");
p.printCell((this.__isNullInDB_name) ?"x":"-");
p.printCell("-");
p.endRow();
p.startRow();
p.printCell("-");
p.printCell("-");
p.printCell("email");
p.printCell(String.valueOf(this.email));
p.printCell((this.__isModified_email) ?"x":"-");
p.printCell((this.__isNullInDB_email) ?"x":"-");
p.printCell("-");
p.endRow();
p.startRow();
p.printCell("-");
p.printCell("-");
p.printCell("password");
p.printCell(String.valueOf(this.password));
p.printCell((this.__isModified_password) ?"x":"-");
p.printCell((this.__isNullInDB_password) ?"x":"-");
p.printCell("-");
p.endRow();
p.startRow();
p.printCell("-");
p.printCell("-");
p.printCell("created_on");
p.printCell(String.valueOf(this.created_on));
p.printCell((this.__isModified_created_on) ?"x":"-");
p.printCell((this.__isNullInDB_created_on) ?"x":"-");
p.printCell("-");
p.endRow();
p.startRow();
p.printCell("-");
p.printCell("-");
p.printCell("is_active");
p.printCell(String.valueOf(this.is_active));
p.printCell((this.__isModified_is_active) ?"x":"-");
p.printCell((this.__isNullInDB_is_active) ?"x":"-");
p.printCell("-");
p.endRow();
p.endTable();
buf.append(out.toString());
return buf.toString();
}
/**
Returns a map of all fields->values (as Strings) contained in this
object. This is useful when sending auto converting the object to JSON, etc.
*/
public Map allFieldsMap()
{
final HashMap m = new HashMap();
m.put("uid", String.valueOf(this.uid));
m.put("name", (name == null ? null : String.valueOf(this.name)));
m.put("email", (email == null ? null : String.valueOf(this.email)));
m.put("password", (password == null ? null : String.valueOf(this.password)));
m.put("created_on", (created_on == null ? null : String.valueOf(this.created_on)));
m.put("is_active", (is_active == null ? null : String.valueOf(this.is_active)));
return m;
}
/* ============== Gets and Sets ============== */
/** serial (INTEGER); PK=yes; Nullable=false; AutoInc=true; MaxSize=10 */
public int get_uid() {
return uid;
}
/** serial (INTEGER); PK=yes; Nullable=false; AutoInc=true; MaxSize=10 */
/* Generating set for set_uid with non public access since it's an auto-increment column */
mollytest set_uid(int uid) {
this.uid = uid;
this.__isModified_uid = true;
this.__isModified = true;
return this;
}
/** varchar (VARCHAR); Nullable=true; AutoInc=false; MaxSize=99 */
public String get_name() {
return name;
}
/** varchar (VARCHAR); Nullable=true; AutoInc=false; MaxSize=99 */
public mollytest set_name(String name) {
this.name = name;
this.__isModified_name = true;
this.__isModified = true;
return this;
}
/** varchar (VARCHAR); Nullable=true; AutoInc=false; MaxSize=99 */
public String get_email() {
return email;
}
/** varchar (VARCHAR); Nullable=true; AutoInc=false; MaxSize=99 */
public mollytest set_email(String email) {
this.email = email;
this.__isModified_email = true;
this.__isModified = true;
return this;
}
/** varchar (VARCHAR); Nullable=true; AutoInc=false; MaxSize=99 */
public String get_password() {
return password;
}
/** varchar (VARCHAR); Nullable=true; AutoInc=false; MaxSize=99 */
public mollytest set_password(String password) {
this.password = password;
this.__isModified_password = true;
this.__isModified = true;
return this;
}
/** date (DATE); Nullable=true; AutoInc=false; MaxSize=13 */
public java.sql.Date get_created_on() {
return created_on;
}
/** date (DATE); Nullable=true; AutoInc=false; MaxSize=13 */
public mollytest set_created_on(java.sql.Date created_on) {
this.created_on = created_on;
this.__isModified_created_on = true;
this.__isModified = true;
return this;
}
/** bool (BIT); Nullable=true; AutoInc=false; MaxSize=1 */
public Boolean get_is_active() {
return is_active;
}
/** bool (BIT); Nullable=true; AutoInc=false; MaxSize=1 */
public mollytest set_is_active(Boolean is_active) {
this.is_active = is_active;
this.__isModified_is_active = true;
this.__isModified = true;
return this;
}
}