的确是慢,hibernate本身就比较慢,设计要求也比较高!学习了...
解决方案 »
- 如何获得oracle中表字段的默认值
- hibernate批量查询优化
- 请问客户端调用webservices出现No such operation 'subscriptionUpdateNotifyRequest'错误,怎么解决
- servlet jsp乱码问题
- 这种情况需要怎么配置软硬件资源
- 数据库表联接问题
- 请高手指点!1、Tomcat5.0配置数据库连接池的问题,initCtx.lookup("java:comp/env");这个参数是什么意思?2、为什么还要把驱动考到Tomca
- 请问,为什么非要用struts里提供的标签
- 有些编译后能用IE看运行,而用appletviewer看却会出错
- EJB客户程序运行出错了,帮忙检查一下!!!!!
- map.entry返回getKey() 和 getValue()问题
- 百度的UE编辑器JSP上传失败
2.检查User表索引
3.User表是否关联了其它表,最好加上lazy
4.改成hql或sql比较下速度
这是映射文件
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping>
<class name="pojo.Customer" table="customer" catalog="mastery">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<!-- 客户简称 -->
<property name="customerShortname" type="java.lang.String">
<column name="customer_name" length="36"/>
</property>
<!--客户代码 -->
<property name="customerCode" type="java.lang.String">
<column name="customer_code" length="36"/>
</property>
.......省略12个字段
</class>
</hibernate-mapping>
POJO类我就不贴了 应该没问题 简单的get set下面是我的Dao查询实现
/**以加载类的形式查询集合 */
@SuppressWarnings("unchecked")
public List<Object> findList(Class entity) throws RuntimeException{
// TODO Auto-generated method stub
return (List<Object>) this.getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(entity));
}
然后我在ACTION每次需要查那个对象我就直接
dao.findList(ABC.class);
关联关系。
<many-to-one name="Customer" class="ifmsMyPriceWeb.pojo.SaleCustomer" lazy="false" insert="false" update="false">
<column name="customer_id"/>
</many-to-one>
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: modifica8_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field10_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field11_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field12_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field13_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field14_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field15_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field16_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field17_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field18_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.loader.Loader.doQuery(699) | result set row: 1
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(172) | returning '8' as column: id3_0_
[QC] DEBUG [http-8080-1] org.hibernate.loader.Loader.getRow(1173) | result row: EntityKey[ifmsMyPriceWeb.pojo.DocShipcompany#8]
[QC] DEBUG [http-8080-1] org.hibernate.loader.Loader.loadFromResultSet(1355) | Initializing object from ResultSet: [ifmsMyPriceWeb.pojo.DocShipcompany#8]
[QC] DEBUG [http-8080-1] org.hibernate.persister.entity.AbstractEntityPersister.hydrate(2031) | Hydrating entity: [ifmsMyPriceWeb.pojo.DocShipcompany#8]
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(172) | returning 'test' as column: shipComp2_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(172) | returning 'test1' as column: shipComp3_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(172) | returning 'test2' as column: shipComp4_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: entryPeo5_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: entryTime3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: modifier3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: modifica8_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field10_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field11_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field12_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field13_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field14_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field15_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field16_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field17_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.type.NullableType.nullSafeGet(166) | returning null as column: field18_3_0_
[QC] DEBUG [http-8080-1] org.hibernate.loader.Loader.doQuery(721) | done processing result set (2 rows)
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.AbstractBatcher.logCloseResults(389) | about to close ResultSet (open ResultSets: 1, globally: 1)
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.AbstractBatcher.logClosePreparedStatement(374) | about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(533) | closing statement
[QC] DEBUG [http-8080-1] org.hibernate.loader.Loader.initializeEntitiesAndCollections(851) | total objects hydrated: 2
[QC] DEBUG [http-8080-1] org.hibernate.engine.TwoPhaseLoad.initializeEntity(107) | resolving associations for [ifmsMyPriceWeb.pojo.DocShipcompany#7]
[QC] DEBUG [http-8080-1] org.hibernate.engine.TwoPhaseLoad.initializeEntity(206) | done materializing entity [ifmsMyPriceWeb.pojo.DocShipcompany#7]
[QC] DEBUG [http-8080-1] org.hibernate.engine.TwoPhaseLoad.initializeEntity(107) | resolving associations for [ifmsMyPriceWeb.pojo.DocShipcompany#8]
[QC] DEBUG [http-8080-1] org.hibernate.engine.TwoPhaseLoad.initializeEntity(206) | done materializing entity [ifmsMyPriceWeb.pojo.DocShipcompany#8]
[QC] DEBUG [http-8080-1] org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(790) | initializing non-lazy collections
[QC] DEBUG [http-8080-1] org.hibernate.transaction.JDBCTransaction.commit(103) | commit
[QC] DEBUG [http-8080-1] org.hibernate.impl.SessionImpl.managedFlush(337) | automatically flushing session
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(58) | flushing session
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(111) | processing flush-time cascades
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.prepareCollectionFlushes(154) | dirty checking collections
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(171) | Flushing entities and processing referenced collections
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(210) | Processing unreferenced collections
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(224) | Scheduling collection removes/(re)creates/updates
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(85) | Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(91) | Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
[QC] DEBUG [http-8080-1] org.hibernate.pretty.Printer.toString(83) | listing entities:
[QC] DEBUG [http-8080-1] org.hibernate.pretty.Printer.toString(90) | ifmsMyPriceWeb.pojo.DocShipcompany{entryTime=null, modificationTime=null, entryPeople=null, id=8, modifier=null, field=null, field5=null, field4=null, field3=null, field2=null, field10=null, field9=null, shipCompanyChineseName=test1, field8=null, field7=null, field6=null, shipCompanyCode=test, shipCompanyEnglishName=test2}
[QC] DEBUG [http-8080-1] org.hibernate.pretty.Printer.toString(90) | ifmsMyPriceWeb.pojo.DocShipcompany{entryTime=null, modificationTime=null, entryPeople=null, id=7, modifier=null, field=null, field5=null, field4=null, field3=null, field2=null, field10=null, field9=null, shipCompanyChineseName=COLUMBUS L, field8=null, field7=null, field6=null, shipCompanyCode=COLUMBUS LINE, shipCompanyEnglishName=COLUMBUS LINE}
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(290) | executing flush
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.ConnectionManager.flushBeginning(469) | registering flush begin
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.ConnectionManager.flushEnding(478) | registering flush end
[QC] DEBUG [http-8080-1] org.hibernate.event.def.AbstractFlushingEventListener.postFlush(321) | post flush
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(201) | before transaction completion
[QC] DEBUG [http-8080-1] org.hibernate.impl.SessionImpl.beforeTransactionCompletion(393) | before transaction completion
[QC] DEBUG [http-8080-1] org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(193) | re-enabling autocommit
[QC] DEBUG [http-8080-1] org.hibernate.transaction.JDBCTransaction.commit(116) | committed JDBC Connection
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(215) | after transaction completion
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.ConnectionManager.afterTransaction(302) | transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
[QC] DEBUG [http-8080-1] org.hibernate.impl.SessionImpl.afterTransactionCompletion(422) | after transaction completion
[QC] DEBUG [http-8080-1] org.hibernate.impl.SessionImpl.close(273) | closing session
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.ConnectionManager.cleanup(380) | performing cleanup
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.ConnectionManager.closeConnection(441) | releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(215) | after transaction completion
[QC] DEBUG [http-8080-1] org.hibernate.jdbc.ConnectionManager.afterTransaction(302) | transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
[QC] DEBUG [http-8080-1] org.hibernate.impl.SessionImpl.afterTransactionCompletion(422) | after transaction completion
#log4j.logger.org.springframework=INFO
#log4j.rootLogger=INFO,appender1
#2) 控制台输出
#log4j.appender.appender1=org.apache.log4j.ConsoleAppender
#log4j.appender.appender1.layout=org.apache.log4j.PatternLayout
#log4j.appender.appender1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}[%p]: %m%n
# 立即输出
#log4j.appender.appender1.immediateFlush=true# log4j.rootCategory=INFO, stdout , R
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout# log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n# log4j.appender.R=org.apache.log4j.DailyRollingFileAppender #log4j.appender.R.File=D\:log4j.log# log4j.appender.R.layout=org.apache.log4j.PatternLayout# log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n# log4j.logger.com.neusoft=DEBUG#log4j.logger.com.opensymphony.oscache=ERROR# log4j.logger.net.sf.navigator=ERROR #log4j.logger.org.apache.commons=ERROR# log4j.logger.org.apache.struts=WARN #log4j.logger.org.displaytag=ERROR #log4j.logger.org.springframework=WARN #log4j.logger.org.apache.velocity=FATAL #log4j.logger.com.canoo.webtest=WARN# log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN #log4j.logger.org.hibernate=DEBUG# log4j.logger.org.logicalcobwebs=WARN