Hibernate object-relational mapping - what does "Sessionbound" mean?

I'm currently trying to take the first steps with Hibernate, but unfortunately I really don't understand what sessionbound means.

Say I have a transition object. After it has become permanent, it has not only an identifier, but also a "session" one. But why is it worth mentioning?

+3
source share
2 answers

A session in Hibernate is closely related to a transaction, and also serves as a first-level cache. Each time you read or store an object, it is automatically attached to the current session (thus, it is placed in the L1 cache).

Most importantly, if the object is attached to a session:

  • ( LazyInitializationException).

  • . , .

+4

, , , spring, , , , :

public class MyRep implements Rep {
   @Transactional
   public MyObject findMyObject(..) { ... }
}

, spring , , :

MyObject o = rep.findMyObject(...);

( spring ). , , , .

+1

All Articles