易截截图软件、单文件、免安装、纯绿色、仅160KB

由将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


相关文档:

维护SQL server的28个小问题

1.如何创建数据库
CREATE DATABASE student
2.如何删除数据库
DROP DATABASE student
3.如何备份数据库到磁盘文件
BACKUP DATABASE student to disk=´c:S4.bak´
4.如何从磁盘文件还原数据库
RESTORE DATABASE studnet from DISK = ´c:S4.bak´
5.怎样创建表?
CREATE TABLE Students (
&n ......

SQL 2005转换成2000 (SQL Server)


直接restore或附加应该是不行的, 用脚本+导数据肯定没有问题。
2005转到2000的步骤
1. 生成for 2000版本的数据库脚本
2005 的manger studio
-- 打开"对象资源管理器"(没有的话按F8), 连接到你的实例
-- 右键要转到2000的库
-- 任务
-- 生成脚本
-- 在"脚本向导"的"选择数据库"中, ......

sql大全


. SQL 命令
这部分包含那些 PostgreSQL 支持的 SQL 命令的信息.这里的 "SQL" 就是该语言通常的含义; 每条命令的与标准有关的兼容性的信息可以在相关的参考页中找到.
Table of Contents
ABORT --  退出当前事务
ALTER GROUP --  向组中增加用户或从组中删除用户 
ALTER USER --  改变数据库 ......

SQL存储过程测试(5)——从T

问题
      如何让T-SQL测试套件把测试用例结果直接写入文本文件
设计
      使用ActiveX技术实例化一个FileSystemObject对象,然后通过OpenTextFile()和WriteLine()方法直接把测试结果写入文件。
方案
declare @fsoHandle int,@fileID int
exec sp_OACreate 'Scr ......

sql 全文索引

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()
注 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号