[code]
<property name=“password” value="SENHA/>
<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>[/code]
onde coloco ou configuro o c3p0? (antigamente era assim)
<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>
até mesmo o envers?
<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" />
E o ehcache?
ps: tudo isso tendo em vista que estou usando LocalContainerEntityManagerFactoryBean e não o **SessionHiber… (aquele especifico do hibernate).
Lá no forum do Spring o povo me respondeu pra quem interesar fica aqui como configurar ehcache spring c3p0 jpa
zti
#3
Nesse exemplo ele mostra como configurar o pool para utilizar como dataSource.
E como eu faria as outras configurações do hibernate utilizando o spring?
como exemplo
[code]
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Configuração de debug -->
<property name="show_sql">true</property>
<property name="hibernate.generate_statistics">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>[/code]
Obrigado
O datasource (penso) não tem muito haver com Hibernate!
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="jdbcUrl" value="jdbc:derby://localhost:1527/base;create=true" />
<property name="user" value="sa" />
<property name="password" value="sa" />
</bean>
As configurações especificas do Hibernate podem ficar no entityManagerFactory !
Dê uma olhada no exemplo abaixo (enfâse no jpaProperties) configurando coisas especificas do hibernate… como até mesmo o Envers.
<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>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.ejb.event.post-insert">
org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-update">
org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-delete">
org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.pre-collection-update">
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.pre-collection-remove">
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-collection-recreate">
org.hibernate.envers.event.AuditEventListener
</prop>
</props>
</property>
</bean>