This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

RE: New to GORM, please advise

Jun 16th, 2011, 12:54 AM

hello,
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.

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: