⑴ SSH 框架+ orcal怎么用sql实现页面查询分页
给你一段
/**
* 实现分页查询
* @param offset 开始索引 start:0
* @param length 查询长度
* @return
*/
public List getListForPage4SQL(final String sql, final int offset, final int length) {
List retList = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.createSQLQuery(sql);
query.setFirstResult(offset);
query.setMaxResults(length);
List list = query.list();
return list;
}
});
return retList;
}
⑵ ssh使用hibernate进行sql查询问题
as col_0_0_这是hibernate内部框架实现,也就是hibernate.dialect。他会把你hql转换sql,主要是根据不同数据库做变化,省去你修改的麻烦。
List<Score_detail> sdList = (List<Score_detail>) getSession().createQuery(hql).list();
这样查询出来,然后遍历list,后用sd.getDep...就能取得你要的字段。
⑶ ssh中的数据库查询语句该怎么写
您好,这样的:
在applicationContext.xml中配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="palceHolderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
abstract="false" singleton="true" lazy-init="default"
autowire="default" dependency-check="default">
<property name="location">
<value>classpath:init.properties</value>
</property>
</bean>
<!--c3p0数据源配置-->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" dependency-check="default">
<property name="driverClass">
<value>${dataSource.driver}</value>
</property>
<property name="jdbcUrl">
<value>${dataSource.jdbcUrl}</value>
</property>
<property name="user">
<value>${dataSource.user}</value>
</property>
<property name="password">
<value>${dataSource.password}</value>
</property>
<property name="acquireIncrement">
<value>${dataSource.acquireIncrement}</value>
</property>
<property name="minPoolSize">
<value>${dataSource.minPoolSize}</value>
</property>
<property name="maxPoolSize">
<value>${dataSource.maxPoolSize}</value>
</property>
<property name="maxIdleTime">
<value>${dataSource.maxIdleTime}</value>
</property>
<property name="idleConnectionTestPeriod">
<value>${dataSource.idleConnectionTestPeriod}</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<!-- 显示sql语句 -->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/vo/Customer.hbm.xml</value>
<value>com/vo/Engineer.hbm.xml</value>
<value>com/vo/Repairplant.hbm.xml</value>
<value>com/vo/Proct.hbm.xml</value>
<value>com/vo/Archives.hbm.xml</value>
<value>com/vo/Account.hbm.xml</value>
<value>com/vo/User.hbm.xml</value></list>
</property>
</bean>
<bean id="engineerDAO" class="com..impl.EngineerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="repairplantDAO" class="com..impl.RepairplantDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="proctDAO" class="com..impl.ProctDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="archivesDAO" class="com..impl.ArchivesDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="accountDAO" class="com..impl.AccountDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userDAO" class="com..impl.UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="customerDAO" class="com..impl.CustomerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
这样就可以在调试的时候显示sql语句了。
⑷ ssh 对数据表查询出错。警告: SQL Error: 1064, SQLState: 42000
CREATE TABLE #order ( id varchar(30) NOT NULL, username varchar(10) NOT NULL, proctid int NOT NULL, ordertime time NOT NULL, num int NOT NULL, state int NOT NULL, PRIMARY KEY (id))
这样就ok了,不明白可追问
⑸ ssh框架用sql查询出来的一个list如何在页面显示
el表达式应该能搞定吧