Seeking a Spring (3.0.5) Solution for: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here?

It sounds like you are doing everything correctly and you know what you are doing. There's not much we can do here unless you show some configuration.

It sounds like you are doing everything correctly and you know what you are doing. There's not much we can do here unless you show some configuration. What I'd suggest is some debugging.

First: do you have Unit tests in the service layer that test the queries you are using? Perhaps you can find the error in the service layer. Then: debug the MVC app, check the types of the injected services.

Verify that they are proxies, not the original types. If they are the original types, you have an error in your transaction configuration . If they are proxies, step through the query methods and verify that the transaction logic is applied.

This sounds like accessing a lazily-loaded list or set of you dao after the closing of the transaction. This typically happens if you access that list in the view in stead of the controller, as your controller probably calls methods in transaction scope, and then leaves the transaction and forwards the loaded bean to the view. Simple solutions: Configure your data bean to eagerly load Force loading of the dependencies in the controller (just loop through them) have a look at this article ans possibly also quite a few right here on SO on lazy loading / lazy fetching of one-to-many associations and the like Imagine: // your dao public class Foo { // lots of other properties List stuff; // getters and setter for stuff } // repository @Transactional public class FooRepo { public Foo loadFoo(int id) { ... } } // Controller public class Controller { public void Control() { sessionContext.

Set("foo", repo. LoadFoo(1)); // transaction managed by spring } public void setFooRepo(FooRepo repo) {this. Repo = repo}; } // View for (Something something : foo.getStuff()) { // Ooops transaction is closed!

Stuff is lazily loaded so NOT AVAILABLE // practical solutions: // - do not load lazily (Foo.hbm. Xml) // - or force loading by getting all Somethings in the controller }.

I believe that my problem has nothing to do with your described scenario. The problem starts at the opening of a session. At that point my program terminates.It never get the chance of hitting the database.

Therefor I think that it is not a lazyload issue. – Ursus Feb 28 at 0:18.

This sounds like accessing a lazily-loaded list or set of you dao after the closing of the transaction. This typically happens if you access that list in the view in stead of the controller, as your controller probably calls methods in transaction scope, and then leaves the transaction and forwards the loaded bean to the view.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions