I am trying to load some bootstrap data into the database on
Application startup. I have the following class which does that.
-------------------------------------
@OnApplicationStart
public class Bootstrap extends Job<Bootstrap> {
public void doJob() {
try{
if (Installation.count() == 0) {
Logger.debug("Loading data.............");
Fixtures.loadModels("initial-data.yml");
Logger.debug("Done!");
}
}
catch(Exception exc)
{
exc.printStackTrace();
Logger.error("exception caught!!" + exc);
}
}
}
----------------------------------------------------------------
initial-data.yml
---------------------------------
Installation:
name: "HNC-1"
installCode: "HNC-1"
description: "Installation -1"
Installation:
name: "HNC-2"
installCode: "HNC-2"
description: "Installation -2"
-----------------------------------------------------------
Installation model class
--------------------------
@Entity
@Table(name = "installation",uniqueConstraints =
@UniqueConstraint(columnNames = {"name", "install_code"}))
public class Installation extends Model{
@Required
public String name;
@Required
@Column(name="install_code")
public String installCode;
public String description;
public Installation(String name, String installCode, String
description) {
this.name = name;
this.installCode = installCode;
this.description = description;
}
}
---------------------------------------------
The class is getting called fine and the data import seems to happen,
but I don't see anything saved in the database.
Any ideas as to why this is happening?
Thanks in advance.