The EntityManager is the representation of a PersistenceContext, allowing a user to manipulate data pulled from a database.
Questions tagged [entitymanager]
1802 questions
6
votes
1 answer
How to attache detached entity in Doctrine?
I have a script which saves some new entities of type "A" in the loop to the database. But the loop can throw some exceptions which close entityManager. So it must be reopen. It causes that another entity of type "B" which should be joined with…

Čamo
- 3,863
- 13
- 62
- 114
6
votes
7 answers
How to use JUnit tests with Spring Roo? (Problems with EntityManager)
I'm trying to write a JUnit test for a Spring Roo project. If my test requires use of the entity classes, I get the following Exception:
java.lang.IllegalStateException: Entity manager has not been injected
(is the Spring Aspects JAR configured as…

Eric Wilson
- 57,719
- 77
- 200
- 270
6
votes
2 answers
Injecting EntityManager in servlet, it seems not thread safe
I want to make a login app in Java EE. I thought of implementing it using a html page, a servlet and an entity class for the user, but it seems that EntityManager is not thread safe (can't be injected in the servlet and I need it to check the…

something
- 90
- 9
6
votes
2 answers
create entity manager programmatically without persistence file
I'm trying to create entity Factory manager programmatically without persistence file
EntityManagerFactory emf;
Map properties = new HashMap();
properties.put("hibernate.connection.driver_class",…

tamtoum1987
- 1,957
- 3
- 27
- 56
6
votes
1 answer
Using entityManager to get list from database
I've been working within the Spring MVC and have absolutely no clue what I'm doing. I'm trying to retrieve a list of objects (or records) from a database using entityManager. I have my method that doesn't seem to do anything:
@Override
public…
user1750824
6
votes
3 answers
Is there a stateless version of the JPA EntityManager?
Hibernate has a Stateless Version of its Session: Does something similar exist for the JPA EntityManager? I.e. an EntityManager that does not use the first level cache?

Jens Schauder
- 77,657
- 34
- 181
- 348
6
votes
1 answer
Hibernate EntityManager: remove referenced entity not working
I'm currenetly trying hard to delete an entity, that is involved in various relations (Only @ManyToOne) - However, Hibernate does not delete anything - after calling em.remove everything remains unchanged.
I have 5 entities (E1 - E5), referencing…

dognose
- 20,360
- 9
- 61
- 107
6
votes
1 answer
How to get jpa datasource properties from Entity Manager
Hi everybody
I was wondering if it's possible to get database connection properties through entity manager.
My persistence.xml looks like this
…

Stoffelchen
- 95
- 2
- 2
- 6
6
votes
3 answers
Transaction required exception on execute update for JPQL update query
I get this error when I try to run this code.
Error:
javax.persistence.TransactionRequiredException: executeUpdate is not supported for a Query object obtained through non-transactional access of a container-managed transactional EntityManager…

user2233876
- 61
- 1
- 1
- 2
6
votes
4 answers
Heroku/Play/BoneCp connection issues
I have an app on heroku that uses play. It was working fine for the longest time, but somewhat recently I started getting this:
Caused by: java.sql.SQLException: Timed out waiting for a free available connection.
at…

radu--
- 108
- 1
- 6
6
votes
2 answers
Can Spring/JPA/Hibernate use simple JDBC-compliant driver?
We have an application which uses a Spring container on the server which uses EJB3 entities and Hibernate to persist data in a PostgreSQL database.
I'd like to add another connection to a separate database using a separate EntityManager, but the…

DuncanKinnear
- 4,563
- 2
- 34
- 65
6
votes
3 answers
Handle multiple EntityManager in Java EE application
I have Java EE application with about 10 EntityManagers (number of EMs will probably increase). My application also contains many stateless, statefull and message driven beans.
Rather than inject in each bean my EMs with @PersistenceContext (and 2…

Olivier J.
- 3,115
- 11
- 48
- 71
6
votes
2 answers
EntityManager cannot use persist to save element to database
I met the problem of persisting element to database using EntityManager. Based on the answers I found, I tried those 4 ways in my DaoJpa to do such thing but still failed. Here I attached the four ways I tried:
Code in Controller part:
…

Qingshan Zhang
- 245
- 1
- 3
- 12
6
votes
2 answers
How to use entityManager inside Entity?
I have this function in Entity class but the getDoctrine do not fond...
public function getObject()
{
$em = $this->getDoctrine()->getEntityManager();
switch($this->objectType)
{
case 'video':
return…

Antoine Lenoir
- 524
- 1
- 3
- 17
6
votes
1 answer
detached entity passed to persist
used: hibernate 3.6.10, maven 2, postgres 9.
I have code that must work but it doesn't.
before I used hibernate 3.6.2 and got really frustrated error:
java.lang.ClassCastException: org.hibernate.action.DelayedPostInsertIdentifier cannot be cast to…

Dmitrii Borovoi
- 2,814
- 9
- 32
- 50