Announcement

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

    Question regarding data source usage...

    Hi all.. I'm a SmartGWT newbie and am trying out some initial toying around with a small project. When I first started this mini-project I was using JPA annotations and wrote java classes describing each domain object. However, after reading the docs further I decided I'd use the datasource xml files (*.ds.xml) instead and gather I could get rid of the individual java files with their getter/setter methods. So, I'm trying that with one class for starters to see if it works like I'd expect..

    So, I'm having a little trouble as I can't find any example in the included examples that shows this particular way from what I can see -- all of them use the hand-built java classes for each domain object.. I had a persistence.xml file which I gather isn't needed but did need to have a server.properties file that indicates how to connect to my database. The issue that I'm having is that I'm not seeing any sort of database activity..

    I do have a ds.xml file describing a table with the fields.. I've also got some lines in my "html" file (myproject.html) that loads the datasource stuff but I do NOT have any "Datasource.get" lines in the code as of yet.. IF I want to force the database to create the table(s) up-front, is there something special needed or do I just create a method in my EntryPoint class that will force a seed of the database (which in turn might create the missing db)?? I'm sorry if this is something stupid but I just can't find the obvious answer in the docs or on the wiki..

    Thanks in advance..

    #2
    Perhaps I should start over by asking one simple question -- do I (or do I not) need to build my own java classes that describe my domain objects? Reading the docs indicates that the best way is to NOT do this unless you've got prior objects using Hibernate or JPA,etc.. Since I'm starting fresh I'm looking for the best approach. Whatever approach is taken I will need to add some initial sample data and it would be nice to be able to blow the database away programmatically IF I change the layout from build to build. I gather I can do that with Hibernate/JPA's persistence.xml file as one of the options -- I did that with a unit test last week and it worked fine... but if I can get faster performance NOT using Hibernate/JPA that's fine too.. Can someone elaborate here?

    Comment


      #3
      It's not that clear what you're trying to do or what you're asking for help with, exactly. If you haven't read the Quick Start guide, start there.

      If you just want some pretend schema/data for prototyping, you could use the hsql database that comes with the sdk, and expand on what's there if you want. This maven archetype sets up some datasources around 2 of those tables.

      Otherwise I think there's an option to have the VisualBuilder tool create your schema (and add test data if I'm not mistaken) from a ds.xml (quick forum search yields this).

      Comment


        #4
        See the QuickStart Guide - SQLDataSource is our first recommendation. You can use the Admin Console to generate SQL tables from your .ds.xml definition, as well as import sample data to those tables (see Admin Console docs for approaches).

        For completeness, Hibernate can also work without the need to create a Java bean, JPA does not have this capability at all. Again SQLDataSource is the first choice, as it is faster, more flexible and simpler.

        Comment


          #5
          Thanks.. I've already read the quickstart guide several times (not all of it mind you -- just to first 8 or so chapters). I've not yet looked into the admin console though and perhaps that's the missing piece as I was kinda expecting SQL tables to be created and whatnot similar to what I did with my unit tests. I'll check into this. Thanks!

          Comment


            #6
            Unfortunately you stopped just one chapter short of the chapter that answers all of these questions in detail.

            Comment


              #7
              Ok.. I was able to get my Pro version to fire up the admin console and it found my pre-selected Postgres configuration and it tests out just fine.. Now, I switch over to the "Import Data Sources" tab and it finds nothing even if I press refresh.. Is it looking in a particular location to find my *.ds.xml files? They currently reside in the top-level war/ds directory tree -- perhaps it's looking somewhere else?

              I was also missing the serverType="sql" in the play around data source I've got but it didn't make any obvious difference.

              I think I'm close -- I think if the admin console can see my ds.xml file I can have it create/populate the tables and I'll be good to go.. Thanks!

              Comment


                #8
                It will find them in that location, which is the default.

                Check your server-side log for exceptions that may be occurring when you go to that tab.

                Comment


                  #9
                  Ok.. Got it working for the most part.. I had some issues with a couple of XML files that were malformed for some of the tags.. I ran the XML validate feature of Eclipse and it found the issues.. The only thing I can't figure out is why the importing of test data didn't work.. I checked the box saying to do that but it didn't bring anything in but did create the schema fine in Postgres..

                  Comment


                    #10
                    Here again the server-side will tell you what is going wrong, eg, file not present at the path you specified, malformed XML again, etc.

                    Comment


                      #11
                      By the way.. In running the code and looking closer at the logs I see lots of the following :

                      Code:
                      === 2012-01-06 20:34:44,735 [l0-6] DEBUG BuiltinRPC - Loading DS: rbCountryTransactions
                      === 2012-01-06 20:34:44,735 [l0-6] WARN  DataStructCache - File rbCountryTransactions.ds not found at explicitly specified location /Users/nrf/projects/smartgwt/myproj/war/myproj/sc/system/reference/inlineExamples/serverExamples/transactions/rollback, checking project-wide area
                      === 2012-01-06 20:34:44,735 [l0-6] WARN  BuiltinRPC - Couldn't load config-defined datasource: rbCountryTransactions
                      === 2012-01-06 20:34:44,735 [l0-6] DEBUG BuiltinRPC - Loading DS: supplyItemWithOps
                      === 2012-01-06 20:34:44,736 [l0-6] WARN  DataStructCache - File supplyItemWithOps.ds not found at explicitly specified location /Users/nrf/projects/smartgwt/myproj/war/myproj/sc/system/reference/inlineExamples/grids/ds, checking project-wide area
                      === 2012-01-06 20:34:44,736 [l0-6] WARN  BuiltinRPC - Couldn't load config-defined datasource: supplyItemWithOps
                      === 2012-01-06 20:34:44,736 [l0-6] DEBUG BuiltinRPC - Loading DS: queuedAdd_orderItem
                      === 2012-01-06 20:34:44,736 [l0-6] WARN  DataStructCache - File queuedAdd_orderItem.ds not found at explicitly specified location /Users/nrf/projects/smartgwt/myproj/war/myproj/sc/system/reference/inlineExamples/serverExamples/sql/queuedAdd, checking project-wide area
                      What setting in my project is controlling this and what can get chopped out to remove these?

                      P.S. One of the issues I had was a missing log4j config file.. All fixed now of course!!

                      Also, I fixed the issue with no test data loading via the admin console. I had defined the "id" field to be a primary key sequence but marked it with required="true" which was causing the validation logic to kick it out.. Once the required keyword was removed the test data shows up just fine.. Very nice!!!
                      Last edited by Rick.F; 6 Jan 2012, 21:32.

                      Comment

                      Working...
                      X