Announcement Announcement Module
No announcement yet.
RE: New to GORM, please advise Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RE: New to GORM, please advise

    I posted this question in the data section but have not received any feedback. Please advise me on the below question:

    I have a system that poles a data source and stores the results in a table. Both the original source and the storage destination have the save database design, one parent and several children in a one-to-many design. I need to design a way to compare the new data set (that comes from the poled data source) with the old data set (which comes from the stored database) and update the stored data set with the most up to date records. Each record has a time stamp for when it was created and last updated. so, this system needs to take the following rules into consideration:

    1. compare each parent record, if the data from data set 1 = the data from data set 2 do nothing (its already updated).
    2. if the data from data set 1 is more recent then data set 2 update data set 2.
    3. if the data from data set 1 is older then data set 2, do nothing (its already updated)
    4. if the data from data set 1 was deleted but still exists in data set 2, remove it.

    Then, this same process needs to occur for all the children records. Essentially, i just need to know how to syncronize to data sets. If I weren't using GORM i would just iterate through each record set using SQL. How can i do this using GORM? Doing the parent isnt difficult the problem i've been having is with the children.


  • #2
    It's difficult to know how you should do this without understanding your requirements and the nature of the original data source. The fact that you can currently manage the parent OK seems to suggest you can handle the children without much problem either. What issue are you having?

    If you really want, you can use JDBC directly. Simply create a service with a 'def dataSource' property and use 'dataSource' to connect to the database. For example, using Groovy SQL you can do this:

    class DataSyncService {
        def dataSource
        def sync() {
            def sql = new groovy.sql.Sql(dataSource)