You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by awold <aw...@hotmail.com> on 2010/11/15 18:33:08 UTC

Using a JPA based idempotent repository ~

I’ve been trying to set up a working example of using a jpa store for
idempotent file handling with Hibernate and it’s not quite working.  I’m
currently using an H2 database.  Everything seems to start up fine until it
tries to persist the message processed entity (that's #4 below).  But I also
have some general questions too.


1) Am I forced to use OpenJPA?  My project uses Hibernate and thus I’ll
already have an entity manager created, etc.


2) CAMEL_MESSAGEPROCESSED and OPENJPA_SEQUENCE_TABLE tables are created
automatically but nothing was in the OPENJPA_SEQUENCE_TABLE table.  Should a
record have been created automatically in this table?


3) Having CAMEL_MESSAGEPROCESSED and OPENJPA_SEQUENCE_TABLE tables created
automatically in a production db is probably not going to fly.  What would
be the best approach to creating DDL statements for these tables?  I
downloaded the Apache Camel 2.5.0 and did not find any creation scripts.  I
understand that the DDL script could vary by DB, but it seems like this
could be a common issue so an ANSI SQL compliant DDL script could/should be
shipped I would think.


4) Here is the error I’m receiving.  Why isn’t ID being generated?  In my
console I see a select against CAMEL_MESSAGEPROCESSED, then an insert.  But
never an operation against OPENJPA_SEQUENCE_TABLE to generate an ID.




2010-11-15 09:52:54,347 [B2BClinicalData] DEBUG GenericFileOnCompletion       
- Done processing file: GenericFile[Doc 1.txt] using exchange:
Exchange[Message: GenericFile[Doc 1.txt]]

2010-11-15 09:52:54,347 [B2BClinicalData] DEBUG SQL                           
- select messagepro0_.id as id0_, messagepro0_.messageId as messageId0_,
messagepro0_.processorName as processo3_0_ from CAMEL_MESSAGEPROCESSED
messagepro0_ where messagepro0_.processorName=? and messagepro0_.messageId=?

2010-11-15 09:52:54,362 [B2BClinicalData] TRACE StringType                    
- binding 'FileConsumer' to parameter: 1

2010-11-15 09:52:54,362 [B2BClinicalData] TRACE StringType                    
- binding 'Doc 1.txt' to parameter: 2

2010-11-15 09:52:54,378 [B2BClinicalData] DEBUG SQL                           
- insert into CAMEL_MESSAGEPROCESSED (id, messageId, processorName) values
(null, ?, ?)

2010-11-15 09:52:54,378 [B2BClinicalData] TRACE StringType                    
- binding 'Doc 1.txt' to parameter: 1

2010-11-15 09:52:54,378 [B2BClinicalData] TRACE StringType                    
- binding 'FileConsumer' to parameter: 2

2010-11-15 09:52:54,394 [B2BClinicalData] WARN  JDBCExceptionReporter         
- SQL Error: 90006, SQLState: 90006

2010-11-15 09:52:54,394 [B2BClinicalData] ERROR JDBCExceptionReporter         
- NULL not allowed for column "ID"; SQL statement:
insert into CAMEL_MESSAGEPROCESSED (id, messageId, processorName) values
(null, ?, ?) [90006-144]






<persistence-unit name="samplePU" transaction-type="RESOURCE_LOCAL">
      
<class>org.apache.camel.processor.idempotent.jpa.MessageProcessed</class>
</persistence-unit>




    <bean id="transactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
        <property name="transactionManager">
            <bean class="org.springframework.orm.jpa.JpaTransactionManager">
                <property name="entityManagerFactory"
ref="entityManagerFactory"/>
            </bean>
        </property>
    </bean>

	<bean id="dbDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
		<property name="driverClassName" value="org.h2.Driver" />
		<property name="url" value="jdbc:h2:tcp://localhost/~/test;USER=sa" />
		<property name="username" value="sa" />
		<property name="password" value="" />
	</bean>

    <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>
    
	<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dbDataSource" />
		<property name="jpaVendorAdapter">
			<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="database" value="${ecdi_db.type}" />
				<property name="showSql" value="false" />
				<property name="generateDdl" value="false" />
			</bean>
		</property>
	</bean>
 
    <bean id="jpaStore"
class="org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository">
        <constructor-arg index="0" ref="jpaTemplate"/>
        <constructor-arg index="1" value="FileConsumer"/>
    </bean>


-- 
View this message in context: http://camel.465427.n5.nabble.com/Using-a-JPA-based-idempotent-repository-tp3266073p3266073.html
Sent from the Camel - Users mailing list archive at Nabble.com.