3 Replies Latest reply on Feb 9, 2015 2:40 AM by Jorge Morales

    JPA vs SQL binding

    Max Ozkin Apprentice


      What are the pros/cons of JPA and SQL bindings?

      If a component has to read/write from/to RDBMS, what one should consider when selecting references with JPA vs SQL binding?

        • 1. Re: JPA vs SQL binding
          Max Ozkin Apprentice

          Does anyone have a working example of mysql-ds.xml file and could explain what's the right procedure to define own datasource?


          My mysql-ds.xml looks following:


          <datasources xmlns="http://www.jboss.org/ironjacamar/schema">

             <datasource jndi-name="java:jboss/datasources/MySqlDB" pool-name="MySQLPool">













          My composite reference has SQL binding which refers to data source: "java:jboss/datasources/MySqlDB".

          My application is packages as war file and mysql-ds.xml is located in WEB-INF directory.


          But deployment fails with the error:

          "JBAS014771: Services with missing/unavailable dependencies" => ["jboss.data-source.java:jboss/datasources/MySqlDB is missing [jboss.jdbc-driver.mysql-connector-java-5_1_34-bin_jar]"]


          Any ideas what's wrong?

          • 2. Re: JPA vs SQL binding
            Max Ozkin Apprentice

            Ok, above problem was solved by changing <driver> to "mysql"...

            • 3. Re: JPA vs SQL binding
              Jorge Morales Master

              Hi Max,

              From my point of view, JPA requires you to have JPA entities and persistence unit, but if you have that it is much simpler to use than the current SQL Binding. It is true that in SwitchYard 2, the camel-sql component will be based on camel 2.14 and use will be simplified, as it used to be a hell (required you to use an Iterator to get the values).

              So the answer, in my opinion, depends on how are you going to manage your data objects in your application. For simple use cases, the SQL component might be simpler, for complex use cases, you'll end up having your entity objects as JPA entities, so it wil be much easier to use the JPA component.


              This is just MY opinion.