You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mark Webb <el...@gmail.com> on 2010/12/01 22:38:48 UTC
Spring/Hibernate and transactions
I have a simple route that receives messages, converts them to an
@Entity class and attempts to write the data to a database. I would
like to use Spring/Hibernate to perform this task along with a
TransactionManager. I have been reading through the Camel In Action
chapter #9 and following the example. From what I can tell, I should
be using JDBC, but should there be a different if I want to use Spring
and Hibernate? In my activemq.xml file I import a file where I have
my camel routes and other beans defined. In this file I have the
following:
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://127.0.0.1:61616" />
</bean>
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="transacted" value="true" />
<property name="transactionManager" ref="txManager" />
</bean>
<bean id="txManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean name="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
Just like what is in the book. In another file I have my
hibernate.cfg.xml file which lists the connection information required
to connect to the database. When I run my code, the processor that is
performing the database inserts is not throwing errors, but the code
is not getting into the database. This leads me to believe that the
inserts are happening, but the data is not in the database. I can
query the data and results come back. So can someone please help me
as to what I am doing wrong? Here is a snippet of logging when
ActiveMQ starts up:
INFO | autocommit mode: false
INFO | using driver: org.postgresql.Driver at URL:
jdbc:postgresql://127.0.0.1:5432/xxxxx
INFO | connection properties: {user=xxxxx, password=****}
INFO | RDBMS: PostgreSQL, version: 8.4.5
INFO | JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.4
JDBC4 (build 702)
INFO | Using dialect: org.hibernate.dialect.PostgreSQLDialect
INFO | Using default transaction strategy (direct JDBC transactions)
INFO | No TransactionManagerLookup configured (in JTA environment,
use of read-write or transactional second-level cache is not
recommended)
INFO | Automatic flush during beforeCompletion(): disabled
INFO | Automatic session close at end of transaction: disabled
INFO | JDBC batch size: 15
INFO | JDBC batch updates for versioned data: disabled
INFO | Scrollable result sets: enabled
INFO | JDBC3 getGeneratedKeys(): enabled
INFO | Connection release mode: auto
INFO | Default batch fetch size: 1
INFO | Generate SQL with comments: disabled
INFO | Order SQL updates by primary key: disabled
INFO | Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO | Using ASTQueryTranslatorFactory
INFO | Query language substitutions: {}
INFO | JPA-QL strict compliance: disabled
INFO | Second-level cache: enabled
INFO | Query cache: disabled
INFO | Cache provider: org.hibernate.cache.NoCacheProvider
INFO | Optimize cache for minimal puts: disabled
INFO | Structured second-level cache entries: disabled
INFO | Statistics: disabled
INFO | Deleted entity synthetic identifier rollback: disabled
INFO | Default entity-mode: pojo
INFO | building session factory
INFO | Not binding factory to JNDI, no JNDI name configured