由将SQL查询结果转化为pojo的想到的
今天在网上上看见一篇“将SQL查询结果转化为pojo对象的”博客,博主自定义做了一个类如下:
import java.lang.reflect.Field;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.property.ChainedPropertyAccessor;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.PropertyAccessorFactory;
import org.hibernate.property.Setter;
import org.hibernate.transform.ResultTransformer;
/**
* 完成native sql查询数据(数组)到pojo对象的转化
* @author warison
*
* Oct 26, 2009
*/
public class PojoTransformer implements ResultTransformer {
private static final long serialVersionUID = 1L;
private Class<? extends BaseModel> resultClass;
private Setter[] setters;
private PropertyAccessor propertyAccessor;
public PojoTransformer(Class<? extends BaseModel> resultClass) {
if(resultClass==null)
throw new IllegalArgumentException("resultClass cannot be null");
this.resultClass = resultClass;
propertyAccessor = new ChainedPropertyAccessor(new PropertyAccessor[] { PropertyAccessorFactory.getPropertyAccessor(resultClass,null), PropertyAccessorFactory.getPropertyAccessor("field")});
}
//结果转换时,HIBERNATE调用此方法
&n
相关文档:
1.创建数据库
--exec xp_cmdshell 'mkdir d:\project'--调用DOS命令创建文件夹,使用此句需要启动SQL的外围工具
if exists(select * from sysdatabases where name='数据库名')
drop database 数据库名
set nocount on ......
转自:http://hi.baidu.com/arslong/blog/item/b23307e76252342cb8382001.html
Item01
连接字符串中常用的声明有:
服务器声明:Data Source
、Server
和Addr
等。
数据库声明:Initial Catalog
和DataBase
等。
集成Windows
账号的安全性声明:Integrated
Security
和Trusted_Connection
等。
使用数据库 ......
http://blog.csdn.net/fenglibing/archive/2007/10/24/1841537.aspx
1、将一个表中的内容拷贝到另外一个表中
insert into testT1(a1,b1,c1) select a,b,c from test;
insert into testT select * from test; (前提是兩個表的結構完全相同)
insert into notebook(id,title,content)
se ......
问题
如何让T-SQL测试套件把测试用例结果直接写入文本文件
设计
使用ActiveX技术实例化一个FileSystemObject对象,然后通过OpenTextFile()和WriteLine()方法直接把测试结果写入文件。
方案
declare @fsoHandle int,@fileID int
exec sp_OACreate 'Scr ......
1、要启用全文索引功能首先需要安装full text search全文索引服务
2、启动full text search服务
3、先创建Unique索引和全文索引:CREATE FULLTEXT INDEX ON table_name
4、每个表只允许创建一个全文索引
删除全文索引 DROP FULLTEXT INDEX ON table_name
全文搜索语句,contains(),freeText()
注 ......