Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    JPA2 DataSource?

    Dear Isomorpic guys,

    I am planning to use smartgwt Pro (currently using the eval smartgwtee) with a JPA persistence layer.
    I saw in one Showcase example a comment to a JPA2-aware Datasource, but I could not find the appropriate jar with the loader class JPA2DataSource.class.

    Is JPA2 available and what do I need to get it going?

    Thanks in advance and regards,

    Mark Williams

    #2
    Download a nightly build (smartclient.com/builds) to get the latest JPA support. Be sure to look at the new JPA samples in the Feature Explorer as well.

    Comment


      #3
      Thanks for the quick reply!

      That did it. It works as expected by updating only the isomorphic_jpa.jar.
      I know, its generally not a good idea to mix jars from different releases, but this jar seems isolated and independent enough. Are there any risks doing this?

      It doesnt have to be production safe until the next 6 months, is JPA2 planned to go to production in the next half year?

      Thanks again and best regards,

      Mark

      Comment


        #4
        Definitely don't want to mix resources, just use the new build in it's entirety. It's very close to GA.

        Comment


          #5
          Okay, understood.

          As we are trying to adept the Listgrid to our datasource(s), I realize that I probably have to use custom SQL statements to show all needed columns in the grid (columns referenced from other tables by index).

          Does JPA datasource allow custom statements, the docs only refer to SQL and Hibernate?

          Maybe I am far of the track and displaying columns from different tables in one grid is a lot easier to achieve then by using custom SQL , but I couldnt work it out (except using a selfbuilt data source with dmi).

          Our datamodel consists of loosely joined tables (just connected by indexed columns), no OneToMany relations, so maybe we should drop JPA in favour of Hibernate...

          The history for this "confusion":
          We started with a JPA-based objectmodel with objects referencing other objects / objectlists by using corresponding OneToMany/OneToOne annotations, but this didnt allow us to display foreign columns in the ListGrid too, and populating new records didnt work either

          This is how the model is built:
          class A
          {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          protected long idx;

          private String name;
          ...
          }
          class B
          {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          protected long idx;

          protected long Aidx;

          private String name;
          ...
          }

          We want to see B.name and A.name in a ListGrid showing class B.

          The original JP-Model was:
          class A
          {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          protected long idx;

          private String name;
          ...
          }
          class B
          {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          protected long idx;

          @ManyToOne
          protected A parent;

          private String name;
          ...
          }


          The examples do not cover the aspect of showing foreign columns in a DataBoundComponent when the datasource is serverbased an the tables are coupled by relations.

          Thanks for any hints to get back to the right track and best regards,

          Mark Williams

          Comment


            #6
            In the QuickStart Guide we tell you SQLDataSource is the first choice, and it is. It's simpler, faster, more flexible, takes less effort. If you don't have a pre-existing investment in JPA and a great deal of expertise with it, then you should definitely be using SQLDataSource.

            You can also handle this immediate need, and there are now samples under the JPA folder in the EE Showcase in nightly builds that show doing this. But again SQLDataSource makes this simpler, and handles more difficult cases of customization with ease.

            Comment


              #7
              Thank you for the advice,
              we would have taken this approach if Apache Derby would be supported by smartgwt SQL Datasource.
              As we use the database embedded in our application, we need a database with low / no price per installation, easy administration and capable of handling millions of records. Unfortunately none of the databases supported by smartgwt seems to match this criteria... Therefore we chose JPA (Apache Derby and Firebase).
              I will again check the nightly builds for JPA-related support.

              If this doesnt work, we will probably have to use an approach via RestDataSource und add our own layer between DB and Datasource.

              Thanks again und best regards,

              Mark

              Comment


                #8
                Did you consider HypersonicSQL? (what we include for samples)

                Comment


                  #9
                  Hypersonic is not able to handle updates regarding large quantities of records, we could to divide our databses in "GUI-visible" and "GUI-nonvisible", but it would add a layer of complexity (manually synchronizing IDs between databases.
                  Secondly we want to be able to use extended features like Clustering,Encryption etc. I think H2 (the "successor" of HSQLDB) is capable of all these features and fast and free too!

                  Comment


                    #10
                    I am trying to change my web-app's JDBC code to JPA using ADS Press Hibernate as provider. I am using Eclipse IDE. In that i have defined a MySQL data source. I added it in the persistence.xml. But, I am getting the error. Does anyone else have the same issue?
                    Last edited by elba23; 7 Jul 2013, 21:45.

                    Comment


                      #11
                      Does 2.4/Pro support Derby/Embedded nowadays?

                      Comment


                        #12
                        In theory every DB with JDBC driver should work with JPA - just add driver and configure persistence.xml.
                        Practically, I haven't tested myself.

                        Alius.

                        Comment

                        Working...
                        X