Questions tagged [hibernate-session]

A main Java interface to Hibernate persistence service.

A main Java interface to Hibernate persistence service. The Hibernate Session embodies the concept of a persistence service (or persistence manager) that can be used to query and perform insert, update, and delete operations on instances of a class mapped by Hibernate. Instances may exist in one of three states:

  • transient (never persistent, not associated with any Session)
  • persistent (associated with a unique Session)
  • detached (previously persistent, not associated with any Session)

The ORM tool allows to perform all of these interactions using object-oriented semantics by no longer referring to tables and columns, but using Java classes and object properties. As its name implies, the Session is a short-lived, lightweight object used as a bridge during a conversation between the application and the database. The Session wraps the underlying JDBC connection or Java EE data source, and it serves as a first-level cache for persistent objects bound to it.

The Session object is not intended to be thread-safe, instead a new/current Session should be obtained from the session factory for each thread/transaction.

A Session instance is serializable if its persistent classes are serializable.

126 questions
0
votes
1 answer

hibernate named query xml mapping

If i put a in my Car.hbm.xml the session i get returned from (Session) HibernateUtil.getSessionFactory().getCurrentSession(); is null, if i delete the query from my xml mapping file the session is not null anymore. Why do i get this error?…
krackmoe
  • 1,743
  • 7
  • 29
  • 53
0
votes
1 answer

How to understand PROPAGATION_REQUIRED

I still don't understand the following: method xxx{ Teacher t=dao.get(new Teacher(1)); t.setName("mark"); finder.find(Teacher.class,null,null,null); dao.getSf().getCurrentSession().evict(t); t.setName("ff"); …
0
votes
1 answer

How to manage a map of unsaved entities in Hibernate session?

On my entity (myGroup : Group) I have a collection property (members : HashMap) and I want to allow the user to add multiple new (unpersisted) GroupMembers to the myGroup.members map. The reason why I am using a hashmap for the…
Lisa
  • 4,333
  • 2
  • 27
  • 34
0
votes
2 answers

State of a persistent object in a Hibernate session

I've got a probably embarrassingly easy question regarding Hibernate: When I've got a persisted instance of an object, and some of these object's properties are modified inside the same Session, are those changes visible for me too? Or do I have to…
user321068
0
votes
1 answer

Persisting data in multiple tables in a single transaction

In the code snippet below, I am trying to persist two entities - Account and AccountDetails. I want this to be atomic. Meaning, both the Account and AccountDetails entites should be persisted in a single transaction. I am not able to achieve…
-1
votes
1 answer

Why session.refresh(Object, LockMode.UPGRADE) is deprecated in hibernate?

My Requirement: I am using Quartz cron for triggering purpose, Many triggers are running on same row but base on different column. So when trigger need to update its related column. trigger first refresh(Session.refresh(object)) the object belong to…
Piyush Aghera
  • 965
  • 7
  • 13
1 2 3
8
9