Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC + ComboPooledDataSource (hibernate)
    primarykey
    data
    text
    <p>It's my first time I'm using ComboPooledDataSource in hibernate, but there's something wrong with my configurations I think, so that when I call DAO to retrieve all data from database this returns me nothing.</p> <p><strong>GenView</strong></p> <pre><code>@RequestMapping(value="/getHospitals.ajax") public @ResponseBody Map&lt;String,? extends Object&gt; loadHospitals(){ HashMap&lt;String, List&lt;Hastaneler&gt;&gt; modelMap = new HashMap&lt;String,List&lt;Hastaneler&gt;&gt;(); modelMap.put("hastaneler", genBUS.getHospitals()); return modelMap; } </code></pre> <p><strong>GenBUS</strong></p> <pre><code>@Service @Transactional(isolation = Isolation.DEFAULT, readOnly = false, propagation = Propagation.REQUIRED) public class GenBUS implements IGenBUS { private Log log = LogFactory.getLog(GenBUS.class); @Autowired private SessionClientData scd; @Autowired private GenDAO genDAO; private JdbcTemplate jdbcTemplate; @Autowired private ComboPooledDataSource comboPooledDataSource; @PostConstruct public void dataSource2JdbcTemplate() { this.jdbcTemplate = new JdbcTemplate(comboPooledDataSource); } public GenDAO getGenDAO() { return genDAO; } @Override public List&lt;User&gt; getHospitals() { return genDAO.loadAllObject(User.class); } </code></pre> <p><strong>GenDAO</strong></p> <pre><code>@Repository public class GenDAO extends BaseDAO{ private Log log = LogFactory.getLog(GenDAO.class); @Autowired private SessionClientData scd; @Autowired private ComboPooledDataSource comboPooledDataSource; private JdbcTemplate jdbcTemplate; @PostConstruct public void dataSource2JdbcTemplate() { this.jdbcTemplate = new JdbcTemplate(comboPooledDataSource); } @Autowired public GenDAO(SessionFactory sessionFactory) { logger.debug("GenDAO constructor is called !!!!!!!!"); System.out.println("genDaoooooooooooooooo....."); setSessionFactory(sessionFactory); } </code></pre> <p><strong>BaseDAO</strong></p> <pre><code>public class BaseDAO extends HibernateDaoSupport { protected org.hibernate.impl.SessionFactoryImpl baseSessionFactory; public&lt;T&gt; List&lt;T&gt; loadAllObject(Class&lt;T&gt; clazz) { return (List&lt;T&gt;) getHibernateTemplate().loadAll(clazz); } </code></pre> <p><strong>dao.xml</strong></p> <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans 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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt; &lt;tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" /&gt; &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="baseSessionFactory"/&gt; &lt;/bean&gt; &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" &gt; &lt;property name="location" value="classpath:/resources/test.properties"/&gt; &lt;/bean&gt; &lt;bean id="comboPooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt; &lt;property name="driverClass" value="${database.driverClass}"/&gt; &lt;property name="jdbcUrl" value="${database.url}"/&gt; &lt;property name="properties"&gt; &lt;props&gt; &lt;prop key="user"&gt;${database.user}&lt;/prop&gt; &lt;prop key="password"&gt;${database.password}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;!--&lt;property name="user" value="${database.user}"/&gt; &lt;property name="password" value="${database.password}"/&gt; --&gt; &lt;property name="maxPoolSize" value="50"/&gt; &lt;property name="initialPoolSize" value="2"/&gt; &lt;property name="minPoolSize" value="1"/&gt; &lt;property name="maxStatements" value="200"/&gt; &lt;property name="maxIdleTime" value="300"/&gt; &lt;property name="acquireIncrement" value="10"/&gt; &lt;property name="unreturnedConnectionTimeout" value="90"/&gt; &lt;property name="maxConnectionAge" value="120"/&gt; &lt;/bean&gt; &lt;bean id="baseSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="dataSource" ref="comboPooledDataSource"/&gt; &lt;!-- &lt;property name="entityInterceptor"&gt; &lt;bean class="generic.logging.AuditTrailInterceptor"/&gt; &lt;/property&gt; --&gt; &lt;property name="packagesToScan"&gt; &lt;list&gt; &lt;value&gt;model.GenUser&lt;/value&gt; &lt;value&gt;model.Hastaneler&lt;/value&gt; &lt;value&gt;model.Hastanelerim&lt;/value&gt; &lt;value&gt;model.User&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="cacheProvider" ref="ehCacheProvider"/&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.transaction.factory_class"&gt;org.hibernate.transaction.JDBCTransactionFactory&lt;/prop&gt; &lt;prop key="hibernate.max_fetch_depth"&gt;2&lt;/prop&gt; &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.EhCacheProvider&lt;/prop&gt; &lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.dialect"&gt;${database.dialect}&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.use_sql_comments"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.format_sql"&gt;false&lt;/prop&gt; &lt;prop key="hibernate.generate_statistics"&gt;true&lt;/prop&gt; &lt;prop key="current_session_context_class"&gt;thread&lt;/prop&gt; &lt;!--&lt;prop key="hibernate.hbm2ddl.auto"&gt;none&lt;/prop&gt;--&gt; &lt;/props&gt; &lt;/property&gt; &lt;!-- &lt;property name="eventListeners"&gt; &lt;map&gt; &lt;entry key="pre-insert"&gt;&lt;bean class="generic.logging.HibernateAuditLogListener"/&gt;&lt;/entry&gt; &lt;entry key="pre-delete"&gt;&lt;bean class="generic.logging.HibernateAuditLogListener"/&gt;&lt;/entry&gt; &lt;entry key="pre-update"&gt;&lt;bean class="generic.logging.HibernateAuditLogListener"/&gt;&lt;/entry&gt; &lt;/map&gt; &lt;/property&gt;--&gt; &lt;/bean&gt; &lt;bean id="ehCacheProvider" class="org.hibernate.cache.EhCacheProvider"/&gt; &lt;/beans&gt; </code></pre> <p><strong>test.properties</strong></p> <pre><code>database.url=jdbc:mysql://127.0.0.1:3306/acilservis database.driverClass=com.mysql.jdbc.Driver database.user=root database.password= database.dialect=org.hibernate.dialect.MySQLDialect format_sql=true show_sql=true </code></pre> <p>I'm using Mysql InnoDB as database engine... Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload