Announcement Announcement Module
Collapse
No announcement yet.
How to configure EhCache + Spring + C3P0 + Hibernate (JPA) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to configure EhCache + Spring + C3P0 + Hibernate (JPA)

    I'm trying to configure EhCache, JPA and C3P0 over Spring way. I'm doing this:

    Code:
    	  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
               <property name="driverClass" value="org.apache.derby.jdbc.EmbeddedDriver" />  
               <property name="jdbcUrl" value="URL" />  
               <property name="user" value="LOGIN" />  
               <property name="password" value="SENHA/>  
           </bean>  
        
    
    	<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="jpaVendorAdapter">
    			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<property name="database" value="DERBY" />
    				<property name="showSql" value="true" />
               		<property name="generateDdl" value="true" />
               		<property name="databasePlatform" value="org.hibernate.dialect.DerbyDialect" />
    			</bean>
    		</property>
    	</bean>

    Where do I configure the c3p0? (earlier it was something like that on persistence.xml)
    Code:
       <prop key="hibernate.c3p0.minPoolSize">5</prop>
       <prop key="hibernate.c3p0.maxPoolSize">20</prop>
       <prop key="hibernate.c3p0.timeout">600</prop>
       <prop key="hibernate.c3p0.max_statement">50</prop>
       <prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
    and even the envers framework?
    Code:
       <property name="hibernate.ejb.event.post-insert"
                 value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" />
       <property name="hibernate.ejb.event.post-update"
                 value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" />
       <property name="hibernate.ejb.event.post-delete"
                 value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" />
       <property name="hibernate.ejb.event.pre-collection-update"
                 value="org.hibernate.envers.event.AuditEventListener" />
       <property name="hibernate.ejb.event.pre-collection-remove"
                 value="org.hibernate.envers.event.AuditEventListener" />
       <property name="hibernate.ejb.event.post-collection-recreate"
                 value="org.hibernate.envers.event.AuditEventListener" />
    and the ehcache?

    do you have any example of this uses... or a link.

    best regards,

  • #2
    You will find annation based caching example in the following link

    http://www.rowellbelen.com/content/d...-5-annotations

    Comment


    • #3
      I'm having the same issue. Tried the link resource but that only works for Spring 2.5. Is there anything for Spring 3.X?

      Comment


      • #4
        Here is what I used:

        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass"><value>${jdbc.driver}</value></property>
        <property name="jdbcUrl"><value>${jdbc.url}</value></property>
        <property name="user"><value>${jdbc.username}</value></property>
        <property name="password"><value>${jdbc.password}</value></property>
        <property name="minPoolSize"><value>${c3p0.minPoolSize}</value></property>
        <property name="maxPoolSize"><value>${c3p0.maxPoolSize}</value></property>
        <property name="checkoutTimeout"><value>20000</value></property><!-- Give up waiting for a connection after this many milliseconds -->
        <property name="maxIdleTime"><value>${c3p0.maxIdleTime}</value></property>
        <property name="idleConnectionTestPeriod"><value>${c3p0.idle ConnectionTestPeriod}</value></property>
        <property name="automaticTestTable"><value>${c3p0.automaticT estTable}</value></property>
        </bean>

        Comment


        • #5
          thanks for the info.

          Comment

          Working...
          X