Hi all,

I'm having trouble understanding how to integrate Guice with JPA in my app. 
I mean, I have a working simple project that does write to/queries the 
database (even with unit-tests) [1]. The thing is, when I'm trying to 
implement this behavior in my SWT application (Java SE), I'm not sure how 
to replicate in a best-pratices-only way. I hope you guys can help me 
understand how to correctly use Guice :-)

OK, creating some context, for my DAOs I have this abstract class 
(http://goo.gl/kNYpL) and I implement my DAOs as you can see in this other 
class (http://goo.gl/dtWBo).

Now, the structure of my SWT application:

I have a entry-point class for my app (*MainWindow*) that creates the root 
injector:
    *Injector injector = Guice.createInjector(new JpaPersistModule("appPU"
));*

and initiates the persistence-service by means of an helper-class 
(ApplicationInitilizer.class):

   * injector.getInstance(ApplicationInitializer.class);*
The *MainWindow* instantiates other other windows that will have some stuff 
to do. Some of this stuff is to write some data to the database 
(instantiate DAO and inject EntityManager). Now, the question arises! 
Should I:

* Pass the injector as a constructor parameter for every window I'll need 
to cal my DAOs from?
* Create new injector with different module for each window ?
* User Providers or something else?

Thanks for your help,
PP

1 - https://github.com/pires/simple-jpa-hibernate-guice-desktop-app

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/0d6G8pexdzEJ.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to