Hi,
is it possible to create Entities with a custom factory? I want to create Entity instances via dependency injection like:
@Entiy public class User { private final UserService userService; @Inject private User(UserService userService) { this.userService = userService; ... } } public interface EntityFactory { <T> T create(Class<T> entityClass); } EntityManagerFactory entityManagerFactory = (...); entityManagerFactory.setEntityFactory(myFactory);
The JPA listeners are unsufficient since they are also created without the possibility to inject dependencies (at least without using static variables which are very bad code style). An alternative would be if one can create JPA listener instances inside his application and add this listener via API call to ObjectDB (like .
Is it possible to implement such a functionality? I think this would make a lot of people happier since Hibernate also offers such features.
Thanks and best wishes
Markus