Feb 2nd, 2010, 08:52 AM
Loading data through Roo created scaffolding
I created the Roo persistence scaffolding for a domain I am working on. I need to populate the database using this scaffolding (the data to be populated is currently in a bunch of XML files). Can someone provide a quick example on how to start this? A simple Java "main" that populates a single table will help me get started. I am not looking for reading the files, just how to access the Roo entities from outside of the MVC controllers.
Any help is appreciated.
Feb 2nd, 2010, 07:34 PM
Spring 3 has support for scripts that can be loaded for embedded databases. I am not sure if that fits your use case exactly but it may serve as a good starting point.
Also, if you are using a database like MySql there are usually options to import the data from various sources (SQL, CSV, XML, Excel, etc).
Another option is to create a little bean which reads the XML files at start time and populates the contents to the DB.
Feb 3rd, 2010, 09:32 AM
Thanks for the information. I took a simpler approach by writing a command line application and loading the Spring application context file and using the Roo created entities to load the database. Seems to be working fine.
Feb 3rd, 2010, 05:10 PM
Yes that is another option indeed. This shows the power of Roo since it gives you the full power of Spring.
Tags for this Thread