Thanks for reply me, I could solve the problem, I closed all my sessions after I use it. But even then, I still got some errors, something like "the session is closed or terminated", I got this error because I was manipulating objects in lazy mode (I din't even know that I was in lazy mode). I modified my @OneToMany(cascade = CascadeType.ALL) annotation to @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER). About those methods, sesseion.flush() and session.evict(object), they work just fine, but I could figure out that I had 2 sessions, I was trying to remove the objects in the second one, when the problem was the first 1(I could not rich the first session because my method creates another instance of session, so the object was lost). I have some other issues, but I'll create a new post. Thanks folk.
|