一动态表,已得到数据值存放在OBJ中为一LIST对象,如何得到每个数据的字段值?不用get set
22 回复
returnstr="文件导入数据库成功";
obj = J4E.fromExcel(in, Class.forName(classname),null);
int fieldcount=dao.getEntity(Class.forName(classname)).getMappingFields().size();
int [] objfieldslen=new int[fieldcount];
int [] objfieldslen1=new int[fieldcount];
String [] fieldname=new String[fieldcount];
for(int count=0;count<fieldcount;count++)
{
fieldname[count]=dao.getEntity(Class.forName(classname)).getMappingFields().get(count).getName().trim();
Sql sql = Sqls.fetchInt(String.format("select max(len(rtrim(%s)))*2 from %s",fieldname[count],dao.getEntity(Class.forName(classname)).getTableName()));
objfieldslen[count]=dao.execute(sql).getInt();
objfieldslen1[count]=dao.execute(sql).getInt();
}
for(int count=0;count<obj.size();count++)
{
for(int count1=0;count1<fieldcount;count1++)
{
Mirror mirror = Mirror.me(obj.get(count));
int getvaluelen=0;
if( mirror.getValue(obj.get(count),fieldname[count1])!=null)
getvaluelen=getWordCount(mirror.getValue(obj.get(count),fieldname[count1]).toString());
if(objfieldslen1[count1]<getvaluelen)
objfieldslen1[count1]=getvaluelen;
}
}
String sqlcomm="";
for(int count=0;count<fieldcount;count++)
{
if(objfieldslen1[count]!=objfieldslen[count])
{
if(fieldname[count]!="id")
sqlcomm=String.format("alter table %s alter column %s char(%d);",dao.getEntity(Class.forName(classname)).getTableName(),fieldname[count],objfieldslen1[count]);
}
}
Sql sql = Sqls.create(sqlcomm);
dao.execute(sql);
for(int count=0;count<=obj.size()/1000;count++)
{
if(obj.size()-count*1000>=1000)
dao.fastInsert(obj.subList(count*1000, (count+1)*1000));
else
dao.fastInsert(obj.subList(count*1000, obj.size()));
}
/*int count=0;
for(count=0;count<obj.size();count++)
{
dao.insert(obj.get(count));
}*/
dao.update(Class.forName(classname),Chain.make("drsj",currdate1.parse(currdate)),Cnd.where("drsj","is",null));
用这个满足了我的要求
添加回复
请先登陆