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

java.lang.NoClassDefFoundError: Could not initialize class DataLayer.HibernateAdapter

I have modified my Java project(Web service) into Dynamic web module. I'm using Tomcat 7.0.59 as server. While starting server it is getting started without any issues. But once if I tried to access the Web service method then I will end up with the…
Nani
  • 1,148
  • 3
  • 20
  • 35
0
votes
0 answers

Hibernate Query Time very much different in two different hibernate sessions (Without any 2nd Level Cache enabled)

I am trying to measure the performance of Data Fetching Time by a hibernate query. For this :- a.) I have opened two different sessions and in both sessions, I have used the same Hibernate query. b.) While inside Session1 , time taken is 162…
Aditya Goel
  • 201
  • 1
  • 15
0
votes
1 answer

Data not retrieving after saving in database in hibernate 4

I am using Hibernate 4 with Spring 4. I have created my own session factory and used Hibernate Transaction Manager. I have a problem while retrieving the data after saving. I am saving the data using ProcedureCall and in every method I am opening…
Balkrushn
  • 91
  • 1
  • 1
  • 12
0
votes
1 answer

Hibernate nested transactions / sessions and proxy associations

I am using hibernate 4 and spring-aop to handle transactions so that there is always an open transaction on the server side. I want to create a nested transaction to work on it in isolation but I get an error: Illegal attempt to associate a proxy…
Martins
  • 1,231
  • 2
  • 14
  • 17
0
votes
1 answer

Why System.out.println() can solving my Hibernate Session?

Hello I'm newbie in learning hibernate framework. I was solved my error but I don't know what the problem happen. In my project I have 2 tables Tblbarang and Tbljenis. And 1 field at Tblbarang had relations as foreign key by Tbljenis. I want to…
0
votes
2 answers

What it means that Hibernate Session is single threaded?

The Hibernate documentation says that org.hibernate.Session represents a single-threaded unit of work. I understand that unit of work is used in the context of DB transactions. What does it mean when it says single threaded? please help me in…
Chaitanya
  • 15,403
  • 35
  • 96
  • 137
0
votes
1 answer

createSQLQuery(sql).executeUpdate() not working after inserting the first record

I am calling below method and need to insert records to a table via a stored procedure. In my local machine update works always. In the server update stop after inserting a record. It does not print any exception. My method public void…
user3558691
  • 117
  • 2
  • 12
0
votes
1 answer

ClassMetaData.getPropertyValue() throws LazyInitializationException: could not initialize proxy - no Session

I am trying to get a property value from the class meta data by calling getPropertyValue(Object object , String propertyName , EntityMode entityMode) but it is throwing a org.hibernate.LazyInitializationException: could not initialize proxy - no…
Shahe
  • 964
  • 2
  • 13
  • 34
0
votes
1 answer

Custom Unique Constraint Annotation Spring MVC

I am trying to create custom annotation to check unique field value. For e.g. check unique email address, etc. But cannot autowire 'customerDAO' object. It throws exception 'org.springframework.web.util.NestedServletException: Request processing…
0
votes
1 answer

Reading data with hibernate does not synchronize with the database

I am using hibernate to interact with the database. Insert, delete, update operations there is no problem because of they are ended by a commit statements session.getTransaction.commit(). But While selecting data,listing records hibernate return…
0
votes
1 answer

Session.createQuery() Not Working Properly

I have narrowed down the issue like this: final String[] concreteQueryStrings = QuerySplitter.concreteQueries( hql, factory ); is invoked inside session.createQuery(). Hql param passed to it is = FROM com.persistence.hibernate.pojo.CC WHERE ID =…
Ace
  • 1,501
  • 4
  • 30
  • 49
0
votes
1 answer

Why Junit cases are failed on jenkins, but successed in my local

I am having some junit test cases are running on jenkins, but some of then are failed on jenkins, however I have them ran successfully in my local laptop.org.hibernate.SessionException: Session is closed! at…
Jack Zhang
  • 304
  • 1
  • 9
  • 21
0
votes
2 answers

Correct way to handle the session in hibernate

My code works, I just want to know if it's well written and what I should modify. I used different method to do MySQL selects, with hibernate HQL and with Criteria. Mainly to learn to use them. Another question is about Hibernate session, I don't…
Accollativo
  • 1,537
  • 4
  • 32
  • 56
0
votes
1 answer

Bad configuration of hibernate for spring application?

I have a problems with hibernate in my Spring application. I think that there must be bad configuration. hibernate.cfg.xml
misco
  • 1,912
  • 4
  • 41
  • 68
0
votes
1 answer

why use of hibernatetemplates is eliminated from spring 3.1 on wards?

we are starting a new project and in a confusion whether we can use hibernatetemplates or not. But in many of forums found, use of hibernatetemplates is eliminated from spring 3.1+ on wards. Can any one please provide why hibernatetemplate was…
Pand005
  • 1,095
  • 3
  • 23
  • 53
1 2 3
8
9