I try it with the WorkManager and it works .. thanks =)
public List<Pattern> search(Application app) {
unitOfWork.beginWork();
Criteria criteria = session.get().createCriteria
(Pattern.class);
criteria.add((Expression.eq("idApp",app)))
.add(Expression.ne("isCon", false))
.addOrder(Order.desc("priority"));
return criteria.list();
List<Pattern> result = criteria.list();
unitOfWork.endWork();
return result;
}
On Feb 2, 3:52 pm, Eelco Hillenius <[email protected]> wrote:
> What is your value for current_session_context_class? If it is managed
> (which is the value I think is best), then you need to prepare
> sessions through using WorkManager (beginWork/ endWork, and this is
> Guice managed, so you can have it injected). Or if you're in a servlet
> environment, use wideplay's persistence filter, e.g. like:
>
> public class ServletsModule extends ServletModule {
> @Override
> protected void configureServlets() {
> filter("/*").through(PersistenceFilter.class);
>
> Eelco
>
>
>
> On Tue, Feb 2, 2010 at 6:35 AM, Maurixio <[email protected]> wrote:
> > Hello everyone ... after reading the Dependency Injection book (love
> > this book btw) im trying to put up a project with Guice , Warp and
> > Hibernate ... I have been trying a lot of thing the last week ... and
> > i cant make it work ..
> > im getting :
> > org.hibernate.HibernateException: No session currently bound to
> > execution context (<property
> > name="current_session_context_class">managed</property>)
> > or
> > org.hibernate.SessionException: Session is closed! (<property
> > name="current_session_context_class">thread</property>)
>
> > The configure of guice is like
> > protected void configure() {
> > install(PersistenceService.usingHibernate().across
> > (UnitOfWork.REQUEST).buildModule());
> > bind(Configuration.class).toInstance(new
> > AnnotationConfiguration().configure());
> > ...
> > bind(MyInitializer.class).asEagerSingleton();
> > }
>
> > the MyInitializer.class is like :
> > ..
> > @Inject MyInitializer(PersistenceService service) {
> > service.start();
> > }
> > ..
>
> > and im using it like:
>
> > private final Provider<Session> session;
>
> > @Inject
> > public HibernateFooManager(Provider<Session> session) {
> > this.session = session;
> > }
>
> > @Transactional(type=TransactionType.READ_ONLY)
> > public List<Foo> search(Application app) {
> > Criteria criteria = session.get().createCriteria
> > (Pattern.class);
> > criteria.add((Expression.eq("idApp",app)))
> > .add(Expression.ne("isCon", false))
> > .addOrder(Order.desc("priority"));
> > return criteria.list();
> > }
>
> > Can someone help me , to see what im doing wrong?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "google-guice" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/google-guice?hl=en.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.