Featured post
java - Simplest way of using Hibernate Sessions -
i'm coaching student project uses hibernate persistence layer. projects @ work i'm quite familiar hibernate , can use few 'troubles'. project have problem sessions, stale objects , and 'object loaded different session'-errors.
so looking simplest possible way use sessions:
ideal be:
- sessions can fetched anywhere
- it shouldn't matter whether or not given object loaded session , updated session b
its single-process gui application. current setting current_session_context_class thread. use static field session variable (which think causes of troubles) , fetch once.
thanks assistance!
cheers, reto
assuming you're not teaching orm, understanding of why these errors happen isn't part of knowledge students supposed come away etc etc etc , want hibernate work database wrapper can data use while learning other things.
this best bet:
statelesssession session = sessionfactory.openstatelesssession();
a stateless session "auto-commit mode orm" , close raw-jdbc wrapper hibernate gets. no sessions, no l1 caches, no persistence context. sql/hql returns objects.
- Get link
- X
- Other Apps
Comments
Post a Comment