Defines a
Supplier
used to create a particular
Entity
class. By default the
persistence processor will generate a factory that creates the type using the default zero
argument constructor, however it may be desirable to have an entity with constructor
parameters. When that this the case this annotation must be specified on the entity defining a
Supplier
class that will instantiate the entity. Example:
@Entity
@Factory(PhoneFactory.class)
public class AbstractPhone {
String phone;
AbstractPhone(String phone) {
this.phone = phone
}
}
...
public class PhoneFactory implements Factory<Phone> {
@Override
public Phone create() {
return new Phone("555-5555");
}
}