Announcement Announcement Module
Collapse
No announcement yet.
[HELP] Spring Hibernate query data using MYSQL store procedures Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELP] Spring Hibernate query data using MYSQL store procedures

    I'm using Hibernate3 integrate with spring3, dbcp

    My dispatcher

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="pooledDS" />
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.current_session_context_class">thre ad</prop>
    <prop key="hibernate.connection.useUnicode">true</prop>
    <prop key="hibernate.connection.characterEncoding">UTF-8</prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>/baby/wap/domain/Tblproduct.hbm.xml</value>
    <value>/baby/wap/domain/Tblchannel.hbm.xml</value>
    <value>/baby/wap/domain/Tblwapqplaylog.hbm.xml</value>
    <value>/baby/wap/domain/Tbladvertise.hbm.xml</value>
    <value>/baby/wap/domain/Tbluser.hbm.xml</value>
    <value>/baby/wap/domain/Tblcategory.hbm.xml</value>
    </list>
    </property>
    </bean>
    <bean name="openSessionInViewInterceptor"
    class="org.springframework.orm.hibernate3.support. OpenSessionInViewInterceptor"
    p:sessionFactory-ref="sessionFactory" />
    <bean name="productDAO" class="baby.wap.dao.ProductDAOImpl" p:sessionFactory-ref="sessionFactory" />


    My ApplicationContext


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans [url]http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer"
    p:location="/WEB-INF/hibernate.properties" />

    <!-- bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer"
    p:location="/WEB-INF/jdbc.properties" />

    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource"
    p:driverClassName="${jdbc.driverClassName}"
    p:url="${jdbc.url}"
    p:username="${jdbc.username}"
    password="${jdbc.password}" /-->

    <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->

    <bean name="dbcpDS" class="org.apache.commons.dbcp.BasicDataSource" init-method="createDataSource" destroy-method="close"
    p:driverClassName="${jdbc.driverClassName}"
    p:url="${jdbc.url}"
    p:username="${jdbc.username}"
    password="${jdbc.password}"
    p:defaultAutoCommit="${jdbc.defaultAutoCommit}"
    p:maxActive="${jdbc.maxConnections}"
    p:initialSize="${jdbc.minConnections}"
    p:timeBetweenEvictionRunsMillis="${jdbc.timeBetwee nEvictionRunsMillis}"
    p:minEvictableIdleTimeMillis="${jdbc.minEvictableI dleTimeMillis}"
    p:validationQuery="select 1 from dual"
    p:minIdle="${jdbc.minConnections}"
    p:maxWait="${jdbc.maxWait}"
    p:removeAbandoned="true"
    p:logAbandoned="true"
    p:removeAbandonedTimeout="300"
    p:numTestsPerEvictionRun="${jdbc.numTestsPerEvicti onRun}"
    />
    <bean id="pooledDS" class="org.springframework.jdbc.datasource.LazyCon nectionDataSourceProxy" p:targetDataSource-ref="dbcpDS" />
    </beans>


    And my DAO Impl


    public class ProductDAOImpl extends HibernateDaoSupport implements IProductDAO {

    public List<Tblproduct> getProducts(int category, int start, int limit, int type, int width, int channel) {
    System.out.println("CALL WAPProductGet("+category+","+start+","+limit+","+w idth+","+channel+")");
    Session session = getSession();
    Query query = session.createSQLQuery("CALL WAPProductGet(?,?,?,?,?)")
    .addEntity(Tblproduct.class).setParameter(0, category).setParameter(1, start)
    .setParameter(2, limit).setParameter(3, width).setParameter(4, channel);
    List<Tblproduct> results = query.list();
    session.close();
    return results;
    }
    }


    I'm query data normal but very slow when deploy webserver Tomcat, while many connection mysite very query data slows

    http://bk5.sunkhoai.com

    Please help me
Working...
X