Here is the My Guice Module that I created. It looks like the one in the
archetype. Do I need to bind every DAO? So that then I need to inject the DAO
when it is needed?
public class AppModule extends AbstractModule {
/* (non-Javadoc)
* @see com.google.inject.AbstractModule#configure()
*/
@Override
protected void configure() {
bind(Initializer.class).asEagerSingleton();
//warp persist stuff
install(PersistenceService.usingHibernate()
.across(UnitOfWork.REQUEST)
.transactedWith(TransactionStrategy.LOCAL)
.buildModule());
// hibernate stuff
// default values from development
String connectionUrl = "<the url>";
String username = "<the username>";
String password = "<the password>";
try {
InitialContext context = new InitialContext();
connectionUrl = (String)
context.lookup("java:comp/env/hibernate.connection.url");
username = (String)
context.lookup("java:comp/env/hibernate.connection.username");
password = (String)
context.lookup("java:comp/env/hibernate.connection.password");
} catch (NamingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// annotation and xml
final Configuration config = new Configuration().configure();
config.setProperty("hibernate.connection.url", connectionUrl);
config.setProperty("hibernate.connection.username", username);
config.setProperty("hibernate.connection.password", password);
config.setProperty("hibernate.current_session_context_class",
"managed");
bind(Configuration.class).toInstance(config);
//dao stuff
// DO I NEED TO DO THIS FOR EVERY DAO OBJECT?????
bind(AccountDao.class).to(HibernateAccountDao.class);
bind(CountryDao.class).to(HibernateCountryDao.class);
bind(LanguageDao.class).to(HibernateLanguageDao.class);
bind(TerritorySalesCodesDao.class).to(HibernateTerritorySalesCodesDao.class);
bind(RegionSalesCodesDao.class).to(HibernateRegionSalesCodesDao.class);
bind(CountrySalesCodesDao.class).to(HibernateCountrySalesCodesDao.class);
bind(AccountTypeDao.class).to(HibernateAccountTypeDao.class);
bind(AccountAuditDao.class).to(HibernateAccountAuditDao.class);
}
@Singleton
public static class Initializer {
@Inject
Initializer(com.wideplay.warp.persist.PersistenceService
service) {
service.start();
}
}
}
-----Original Message-----
From: richardwilko [mailto:[email protected]]
Sent: Tuesday, October 06, 2009 2:56 PM
To: [email protected]
Subject: RE: Leg Up for Wicket, Spring, Guice, JPA, Warp, EclipseLink,
Hibernate ... projects
Jeffrey,
I expect the changes you made to the Guice Module are the reason why the
session is null, could you paste in the contents of it.
Regards - Richard Wilkinson
Developer,
jWeekend: OO & Java Technologies - Development and Training
http://jWeekend.com
Jeffrey Schneller wrote:
>
> Thanks for the idea but this didn't work either. Any other ideas? I
> would expect the archetype to work correctly.
>
>
>
> -----Original Message-----
> From: Erik Post [mailto:[email protected]]
> Sent: Tuesday, October 06, 2009 2:09 PM
> To: [email protected]
> Subject: Re: Leg Up for Wicket, Spring, Guice, JPA, Warp, EclipseLink,
> Hibernate ... projects
>
> Hi Jeffrey,
>
> I have *absolutely* no idea if this will help you, but I had the same
> with Spring. It started working when i put the injection annotation on
> the method instead of on the variable.
>
> Good luck,
> Erik
>
> On Tue, Oct 6, 2009 at 7:59 PM, Jeffrey Schneller
> <[email protected]> wrote:
>> I took the archetype for Guice, Warp, Hibernate and modified for my
>> application. All my code looks similar to the code from the archetype.
>> The only difference is I am not using the AnnotatinConfiguration but
>> just the plain Configuration. I am also using c3po connection pooling
>> with Oracle.
>>
>> However, I am still not able to inject the Hibernate Session into my DAO
>> objects. Any ideas? I don't see any exceptions being thrown.
>>
>> �...@inject
>> Provider<Session> session;
>>
>> �...@transactional(type=TransactionType.READ_ONLY)
>> public List<T> findAll() {
>> Criteria criteria =
>> session.get().createCriteria(persistentClass);
>> return criteria.list();
>> }
>>
>>
>> The session in the findAll method is always coming back as <null>.
>>
>> What am I doing wrong? It doesn't seem to be that difficult to
>> implement.
>>
>>
>> Thanks.
>>
>>
>>
>> -----Original Message-----
>> From: jWeekend [mailto:[email protected]]
>> Sent: Tuesday, October 06, 2009 9:48 AM
>> To: [email protected]
>> Subject: Leg Up for Wicket, Spring, Guice, JPA, Warp, EclipseLink,
>> Hibernate ... projects
>>
>> We have launched jWeekend's Leg Up page [1].
>>
>> You can generate a command and run it at your console to create a simple
>> project using one of our archetypes. The projects you will generate will
>> include enough configuration, code and/or some tests to get you started,
>> quickly. Our archetypes currently support various combinations of
>> Spring, Guice, WarpPersist, JPA (with one or more implementation from
>> EclipseLink, Hibernate, OpenJPA) and Wicket.
>>
>> Let us know if this is useful and if you'd like to see more
>> combinations. Also feel free to raise any issues [2].
>>
>> Regards - Cemal
>> jWeekend
>> OO & Java Technologies, Wicket Training and Development
>> http://jWeekend.com
>>
>> [1] http://jweekend.com/dev/LegUp
>> [2] http://code.google.com/p/legup/issues/list
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
-----
http://richard-wilkinson.co.uk My blog: http://richard-wilkinson.co.uk
--
View this message in context:
http://www.nabble.com/Leg-Up-for-Wicket%2C-Spring%2C-Guice%2C-JPA%2C-Warp%2C-EclipseLink%2C-Hibernate-...-projects-tp25769134p25774618.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]