Hello Christian,
       Thank you for the reply. I got this working. I am not getting this
error no more.
But still I am pasting my code snippet so that you can have a look and let
me know if this is the right way to do the things OR if its right, some
other users who come across this problem can use this.

MY ROUTE:
=================
<route>
  <from
uri="jpa:org.apache.camel.example.spring.DarpanTest?consumer.query=select o
from  
darpantesto&amp;consumeDelete=false&amp;maxMessagesPerPoll=5&amp;maximumResults=5"/>
  <to uri="bean:jpatest?method=readContent"/>
</route>

BEANS:
=================

  <bean id="jpatest" class="org.apache.camel.example.spring.JPATest"/>

  <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
  </bean>

  <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="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
  </bean>

   <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="camel"/>
    <property name="jpaVendorAdapter" ref="jpaAdapter"/>
    <property name="dataSource" ref="dataSource" />
  </bean>
  
  <bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="databasePlatform"
value="org.hibernate.dialect.Oracle10gDialect" />
  </bean>
  
  <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"
/>
    <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:SWQA" />
    <property name="username" value="" />
    <property name="password" value="" />
 </bean> 

persistence.xml
===============================
<persistence xmlns="http://java.sun.com/xml/ns/persistence";
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
             version="1.0">

  <persistence-unit name="camel" transaction-type="RESOURCE_LOCAL">
  
    <class>org.apache.camel.example.spring.DarpanTest</class>

    <properties>
      <property name="hibernate.archive.autodetection" value="class"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.format_sql" value="true"/> 
    </properties>

  </persistence-unit>
</persistence>


ENTITY:
=========================
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity(name="darpantest")
@Table(name="darpantest")
public class DarpanTest {

        @Id
        @Column(name="testid")
        private long testid;

        @Column(name="testname")
        private String testname;

    public DarpanTest() {
    }

        public long getTestid() {
                return testid;
        }

        public void setTestid(long testid) {
                this.testid = testid;
        }

        public String getTestname() {
                return testname;
        }

        public void setTestname(String testname) {
                this.testname = testname;
        }
}

BEAN:
======================
public class JPATest {

public void readContent(Exchange test) {
                
                Object obj = test.getIn().getBody();
                DarpanTest d = (DarpanTest)obj;
                System.out.println("########"+d.getTestid()+"#######");
                System.out.println("########"+d.getTestname()+"#########");
        }
}

--
View this message in context: 
http://camel.465427.n5.nabble.com/Help-with-error-while-implementing-camel-jpa-tp5710187p5710917.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to