Questions tagged [hibernate-entitymanager]

Hibernate EntityManager implements the programming interfaces and lifecycle rules as defined by the JPA 2.0 specification.

Hibernate EntityManager implements the programming interfaces and lifecycle rules as defined by the JPA 2.0 specification. For more informatio refer the link.

252 questions
269
votes
8 answers

Hibernate SessionFactory vs. JPA EntityManagerFactory

I am new to Hibernate and I'm not sure whether to use a Hibernate SessionFactory or a JPA EntityManagerFactory to create a Hibernate Session. What is the difference between these two? What are the pros & cons of using each of those?
elpisu
  • 2,695
  • 3
  • 13
  • 4
113
votes
5 answers

How can I get the session object if I have the entity-manager?

I have private EntityManager em; public List getAll(DetachedCriteria detachedCriteria) { return detachedCriteria.getExecutableCriteria("....").list(); } How can I retrieve the session if am using entitymanager, or how can I get the result…
storm_buster
  • 6,806
  • 17
  • 47
  • 69
12
votes
4 answers

javax.persistence.PersistenceException: Unable to build entity manager factory

When I'm trying to create a new EntityManager to persist my data, i get the following Error: javax.persistence.PersistenceException: Unable to build entity manager factory I using the JPA-Persistence Provider of Hibernate... unluckily I couldn't…
nicost
  • 918
  • 2
  • 10
  • 27
10
votes
2 answers

Spring 3.1 + Hibernate 4.1 JPA, Entity manager factory is registered twice

I'm using Spring Framework 3.1 with Hibernate 4.1 as a JPA provider, and I have a fully functional setup, but every time the web app is started I see this warning message: 14:28:12,725 WARN pool-2-thread-12 internal.EntityManagerFactoryRegistry:80…
Wilson Jackson
  • 103
  • 1
  • 1
  • 4
9
votes
3 answers

Hibernate: Unable to access TransactionManager or UserTransaction to make physical transaction delegate

I was using Servlets, PostgreSQL and Hibernate with EntityManager to build a Web app and everything was working ok until I moved the project to a Maven based project. Now I'm getting this weird exception every time I try to create an EntityManager…
keymaker
  • 206
  • 1
  • 2
  • 7
9
votes
3 answers

Hibernate update with EntityManager

I am using Hibernate 4.1.7 and trying to update object, but theres no documentation how it should be done. Currently, I am doing this: Person person = personDao.getPersonById(1); person.setAge(23); person.setLastname("McName"); …
Timo
  • 121
  • 1
  • 2
  • 5
8
votes
1 answer

Spring + EntityManagerFactory +Hibernate Listeners + Injection

i have a simple question. Its possible to add dependency injection via @Ressource or @Autowired to the Hibernate Eventlistener? I will show you my entitymanagerfactory configuration:
moohkooh
  • 857
  • 1
  • 10
  • 25
8
votes
2 answers

JPA with Hibernate 5: programmatically create EntityManagerFactory

This question is specifically about programmatically creating a JPA EntityManagerFactory backed by Hibernate 5, meaning without configuration xml files and without using Spring. Also, this question is specifically about creating an…
Mike Nakis
  • 46,450
  • 8
  • 79
  • 117
8
votes
1 answer

hibernate, mysql, glassfish v3, and JTA datasource

I'm attempting to use hibernate entity manager with mysql and glassfish. I'm getting the following error when attempting to use a JTA datasource: Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the…
KevMo
  • 5,510
  • 12
  • 54
  • 70
8
votes
2 answers

How to enable load time / runtime weaving with Hibernate JPA and Spring Framework

I'm using Hibernate as a JPA provider (I'm using its EntityManagerFactory instead of its SessionFactory) in a Spring Framework application. I managed to get Spring Framework's load time weaving support working, so I'm past that hurdle. I need to…
6
votes
1 answer

JPA EntityManager persist() causing object to appear detached even though an error was thrown

Hi I have a simple DAO with the below function. public element createElement(Element e){ em.persist(e); em.flush(); return e; } The Entity table has a unique constraint on the pair (type,value) and I have a test below: public…
Link19
  • 884
  • 1
  • 17
  • 43
5
votes
3 answers

Declared metamodel attributes work fine BUT Inherited Metamodel Attributes are NULL. Why?

I am not able to run the following test:- @Test public void test() { EntityManager em = entityManagerFactory.createEntityManager(); em.getTransaction().begin(); CriteriaBuilder builder = em.getCriteriaBuilder(); …
dira
  • 28,648
  • 13
  • 50
  • 69
5
votes
0 answers

JPA With hibernate, setting AvailableSettings.USE_CLASS_ENHANCER property to true throws java.lang.ClassCircularityError

I setup spring application. Everything works fine. But when I set Hibernate AvailableSettings.USE_CLASS_ENHANCER property to true then I get java.lang.ClassCircularityError. Here is my configuration. First of all I am using log4j2. Here are my…
Basit
  • 7,824
  • 41
  • 106
  • 185
5
votes
1 answer

Spring 4, Hibernate JPA JarInputStreamBasedArchiveDescriptor Error on Websphere 8.5.5

I have a Spring MVC/Spring-Data-JPA (with Hibernate) application running perfectly on the Websphere 8.5.5 Liberty Profile. However, when I deploy to the full version of Websphere 8.5.5. I get the error pasted below. My other beans naturally rely…
4
votes
1 answer

JPA - createEntityManagerFactory returns Null

Noob question here. I'm following this example/tutorial to try and isolate a problem I keep getting on my main project. Problem is, the entityManagerFactory keeps returning null (thus, I get a NullPointerExcept when trying to run the first JUnit…
Gaston
  • 721
  • 1
  • 14
  • 24
1
2 3
16 17