-
1. Re: EJB Remoting and lazy loading
smarlow Mar 7, 2012 11:04 AM (in response to maximilien)This lazy initialization error will occur when the persistence context has gone out of scope before the lazy fetch has occurred. You shouldn't try to propagate the EntityManager itself but having the remote invocation return detached entities should be fine.
You could make the collection not be lazy but that typically isn't good for performance.
-
2. Re: EJB Remoting and lazy loading
maximilien Mar 8, 2012 10:50 AM (in response to smarlow)Hi Scott,
I don't know if i understand you correctly.
I don't try to propagate the EntityManager, i do something like that
On Client Server
HystoryService service = (HistoryService) context.lookup(
"ejb:"
+
"myapp"
+
"/"
+
"myejb"
+
"/"
+
""
+
"/"
+
"HistoryServiceImpl"
+
"!"
+ org.myapp.ejb.HistoryService.
class
.getName());
Order order = service.getOrder(
"123456");
order.getItems();
And i'd like the proxy makes the lazy loading when i call the getItems.
As you said i could make the collection not be lazy but that typically isn't good for performance.
If i understand you correctly
You shouldn't try to propagate the EntityManager itself but having the remote invocation return detached entities should be fine.
what i do should work and it's more a problem of configuration, that's it ?
-
3. Re: EJB Remoting and lazy loading
maximilien Mar 13, 2012 5:20 AM (in response to maximilien)After some research i realized that remote lazy loading on entities should be possible throught custom hibernate proxy attached to remoting channel but is quite complex to do and is not a best practice.
I've found another architecture for my application that is more standard.
Best regards,