hibernate sql 操作
@SuppressWarnings("unchecked")
public List<ZxFunction> selectFunctionParentByUserId(final int userId) {
try {
final String sql = "select * from zx_function where f_id in ( select distinct f.f_parent_id from zx_function f,zx_permission p where p.f_id = f.f_id and p.u_id = ?)";
return (List<ZxFunction>) getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
SQLQuery query = session.createSQLQuery(sql).addEntity(ZxFunction.class);
query.setInteger(0, 1);
return query.list();
}});
} catch (Exception e) {
CommonsLog4jUtil.printToConsole(e);
CommonsLog4jUtil.error("FunctionDaoImpl public List<UserFunction> selectFunctionParentByUserId() Error:", e);
return null;
}
}
@SuppressWarnings("unchecked")
public List<UserFunction> selectFunction(final int userId) {
try {
final String sql = "select f.f_id as FId,&q
相关文档:
三种SQL分页法效率分析
表中主键必须为标识列,[ID] int IDENTITY (1,1)
1.分页方案一:(利用Not In和SELECT TOP分页)
语句形式:利用Not In和SELECT TOP分页) 效率中,需要拼接SQL语句
SELECT TOP 10 * from TestTable WHERE (Id NOT IN (SELECT TOP 20 id&n ......
一、SQL Server中数据行的存储方式
在SQL Server中存放数据的文件会以8KB的大小分页。每一页可以是数据、索引以及其他SQL Server数据库需要为其维护数据文件的数据类型。大多数页是数据页或索引页。页是SQL Server读、写数据文件的单元。每一页只包括一个对象的数据或索引信息,所以在每一个数据 ......
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......
配置sql server 2000以允许远程访问适合故障:1. 用sql企业管理器能访问sql server 2000(因为它是采用命名管道(named pipes)方式进行方式),但用ado.net 方式(udp)不能访问.2. 采用ado.net方式不能远程访问.故障的可能原因有:1.sql server 2000没有安装sql server 2000 sp3a及以上升级包,还未启用并开放1433端口(udp);2 ......