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.

288 questions
313
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
  • 3,135
  • 3
  • 15
  • 5
123
votes
6 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
  • 7,362
  • 18
  • 53
  • 75
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
  • 1,022
  • 2
  • 11
  • 27
11
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
  • 141
  • 1
  • 2
  • 6
10
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
  • 56,297
  • 11
  • 110
  • 142
10
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
  • 236
  • 1
  • 2
  • 8
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
8
votes
1 answer

required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found

I have a spring boot 2.4.0 application that connects to 2 different data sources. I keep getting this error. I searched for solutions all over internet. I found that I need to specify only one of my beans with @Primary, fact that I also did (so it…
Marius Pop
  • 158
  • 1
  • 4
  • 20
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
  • 917
  • 1
  • 10
  • 25
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,590
  • 13
  • 57
  • 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…
7
votes
2 answers

How to remove the change check in hibernate

Hibernate checks the state of entities when committing transactions. This is useless and performance-critical when fetching large amounts of data to send to the client. I found a solution with entityManager.setFlushMode(FlushModeType.COMMIT); I…
WBLord
  • 874
  • 6
  • 29
7
votes
1 answer

EntityManager merge using specific column other than id

I'm currently using Spring and Hibernate framework, and have an entity with: @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="ID") private Long id; @Column(name="ACC_ID") private Long accId; Now, in a specific case I'd like to…
Jerry
  • 98
  • 1
  • 9
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
  • 586
  • 1
  • 18
  • 47
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
  • 30,304
  • 14
  • 54
  • 69
1
2 3
19 20