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
0 answers

Issues with Hibernate 4.3 to 5.2 upgrade

I am trying to upgrade the Hibernate version of our project from 4.3 to 5.2.I have gone through the steps required for upgrading by going through the following documents https://github.com/hibernate/hibernate-orm/blob/5.0/migration-guide.adoc and…
Ashu
  • 163
  • 4
  • 13
0
votes
0 answers

Error creating bean with the name localContainerEntityManagerFactorryBean defined in the class path resource hibernateconfig.class

I'm getting the Error creating bean with the name localContainerEntityManagerFactorryBean defined in the class path resource hibernateconfig.class. nested exception is javax.persistence.persistenceException:unable to build hibernate session factory:…
bharat
  • 1
  • 1
  • 3
0
votes
1 answer

Spring Config for Hibernate Session

Hi I'm trying to obtain hibernate's Session through Spring's injection. Here's my spring context xml:
0
votes
1 answer

Hibernate Criteria setReadOnly doesn't work on second query

@RequestMapping("/testing") @Transactional public String testing(HttpServletRequest request, final ModelMap model) { Criteria criteria = session.getCurrentSession().createCriteria(Student.class); …
Sam YC
  • 10,725
  • 19
  • 102
  • 158
0
votes
2 answers

Get Hibernate session from JDBC Connection object?

I have a JDBC Connection object which I want to convert into Hibrenate Session. Is there any way by which I can achieve this? I am tried googling, but I'm getting result vice versa.
Sachin Mhetre
  • 4,465
  • 10
  • 43
  • 68
0
votes
1 answer

Using Vaadin Hibernates ThreadLocal.get() returns null after first call

I'm working on a web application in the Vaadin framework to retrieve some data from a MySQL database back-end. The application itself is a survey system to keep track of software consultants skills (and rate them). Some colleagues of mine had…
0
votes
0 answers

Apache Tiles combination with Spring MVC for REST ful Services, Form validation, and Sessions support

Whether Apache Tiles combination is suitable to work with Spring MVC, and Hibernate for REST full Services, Form validation, and Hibernate-Session support. Any other alternative for Apache Tiles?
0
votes
0 answers

How to configure and get session in Hibernate using .properties

All examples that I found contains information about Hibernate.cfg.xml, but I'm using hibernate.properties instead of it. In resources…
Tom Wally
  • 542
  • 3
  • 8
  • 20
0
votes
1 answer

JPA - Hibernate session is closed, but entitymanager works

Given the two line of code : entityManager.find(MyEntity.class, myId); ((Session) getEntityManager().getDelegate()).load(MyEntity.class, myId); The first instruction works fine, but the second one throws org.hibernate.SessionException: Session is…
fego
  • 309
  • 5
  • 20
0
votes
1 answer

Write to multiple DB in single transaction in hibernate

I have a requirement where i need to write to multiple DB. If any exception occurs while writing to anyone of the DBs, i want to rollback everything. E.G. Session userSession= a.getUserDBSession(); Session departmentSession=…
Punky
  • 97
  • 1
  • 12
0
votes
1 answer

Spring mvc integration test with hibernate and jackson-hibernate-mapper: illegal attempt to associate a collection with two sessions

The exception "illegal attempt to associate a collection with two sessions" is well known and happens when same entity is referenced in two different sessions. I have a spring mvc integration test where it happens and need an advice how to make it…
0
votes
0 answers

keep open the Hibernate session with spring MVC application

I am getting an invalid property exception when I am trying to bind a collection in my model object in my form object. I was trying some trick and now I think that the problem is hibernate session with spring MVC , so in the controller I edited…
Ahmed
  • 259
  • 2
  • 9
  • 26
0
votes
2 answers

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: could not initialize proxy - no Session

I do not understand why this is happening. Based on the code path, I should be within the same thread and session should be present, when this exception is raised. Can somebody tell what I am missing here? I have setup
Masoud
  • 63
  • 8
0
votes
0 answers

Hibernate Inconsistent generated Id

I have a main method which sequentially call two web-services. The first web service first insert data into request table which have a primary key that is sequentially generated using hibernate. This table also have one status field whose initial…
vikas27
  • 563
  • 5
  • 14
  • 36
0
votes
1 answer

Transactions on my service layer

I have a Service that has been marked @Transactional. The only problem is, I am working on the method that needs to have it's objects committed at the time I call the save method. I've removed the annotation from the class level and have marked…
Dan
  • 979
  • 1
  • 8
  • 29
1 2 3
8 9