Play! doesn't seem to need a parameterless constructor defined on your Model classes. No exceptions are thrown and everything seems to work fine. However, when a class which doesn't have a parameterless constructor is instantiated when doing Fixtures.load, no inline intialization of fields happen.
For example:
public class MyEntity extends Model {
String name;
List<String> history = new ArrayList<String>();
public MyEntity(String name) {
}
@PrePersist
void created() {
history.add("Created");
}
}
If I do new MyEntity("test").save(), everything works fine; however, when an entity is loaded from a fixture, an exception is thrown at history.add because for some reason history is uninitialised. If I add a default constructor, history is correctly initialised.
This seems like a bug to me, what do you think?
If a default constructor is required, I would expect an exception to be thrown telling me so... if one isn't technically required, then I would expect field initialization to work.
I don't mind adding a default constructor, which is what I'll do, but this does seem like a bit of a grey area.
Thanks