Skip to content

Instantly share code, notes, and snippets.

@cosbor11
Created July 5, 2016 14:28
Show Gist options
  • Save cosbor11/272417322c420cf1162a16f6c92693c8 to your computer and use it in GitHub Desktop.
Save cosbor11/272417322c420cf1162a16f6c92693c8 to your computer and use it in GitHub Desktop.
Main executable class to seed data to showcase the model update examples
public static void main(String[] args) throws EntityException{
// Create a database and its connection
PersistenceManagerFactory factory = new EmbeddedPersistenceManagerFactory(); //1
factory.setCredentials("onyx", "SavingDataisFun!"); //2
String pathToOnyxDB = System.getProperty("user.home")
+ File.separatorChar + ".onyxdb"
+ File.separatorChar + "sandbox"
+ File.separatorChar +"model-update-db.oxd";
// Cleanup the database before we begin
deleteDatabase(pathToOnyxDB);
factory.setDatabaseLocation(pathToOnyxDB); //3
factory.initialize();
PersistenceManager manager = factory.getPersistenceManager(); //5
// Add Some test data
seedData(manager);
// Close the database cleanly
factory.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment