}
public void setSearchByIDSqlPrefix(String searchByIDSqlPrefix) {
this.searchByIDSqlPrefix = searchByIDSqlPrefix;
}
public String getCountSqlPrefix() {
return countSqlPrefix;
}
public void setCountSqlPrefix(String countSqlPrefix) {
this.countSqlPrefix = countSqlPrefix;
}
public String getCountByConditionSqlPrefix() {
return countByConditionSqlPrefix;
}
public void setCountByConditionSqlPrefix(String countByConditionSqlPrefix) {
this.countByConditionSqlPrefix = countByConditionSqlPrefix;
}
}
private TableCache cache = null;
public Table(Class
this.beanClass = beanClass;
this.rowMapper = rowMapper;
this.tableName = tableName;
this.tableKey = tableKey;
this.autoGeneratePK = autoGeneratePK;
this.dateFormat = dateFormat;
init();
}
public Table(Class
}
public void init() {
cache = new TableCache();
BeanWrapper beanWrapper = null;
try {
beanWrapper = new BeanWrapperImpl(beanClass.newInstance());
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
cache.setKeyDescriptor( beanWrapper.getPropertyDescriptor(tableKey) );
cache.setProperties(new ArrayList
{
for (PropertyDescriptor descriptor : beanWrapper.getPropertyDescriptors()) {
String name = descriptor.getName();
if (!beanWrapper.isWritableProperty(name)
|| (getAutoGeneratePK() && name.compareToIgnoreCase(getTableKey())==0)){
continue;
}
cache.getProperties().add(descriptor);
}
}
cache.setKeyGetMethod(cache.getKeyDescriptor().getReadMethod());
cache.setKeySetMethod(cache.getKeyDescriptor().getWriteMethod());
cache.setDeleteSqlPrefix("delete from "+tableName+" where "+tableKey+"="+getHoldFlag(cache.getKeyDescriptor()));
cache.setSearchByIDSqlPrefix("select * from "+tableName+" where "+tableKey+"="+getHoldFlag(cache.getKeyDescriptor()));
cache.setSearchSqlPrefix("select * from "+tableName+" where ");
cache.setCountSqlPrefix("select count(1) from "+tableName);
cache.setCountByConditionSqlPrefix("select count(1) from "+tableName+" where ");
{
StringBuffer tempColumns = new StringBuffer();
StringBuffer tempValueHolds = new StringBuffer();
for (PropertyDescriptor descriptor : cache.getProperties()) {
String name = descriptor.getName();
if (!beanWrapper.isWritableProperty(na