Questions tagged [entitymanager]

The EntityManager is the representation of a PersistenceContext, allowing a user to manipulate data pulled from a database.

1802 questions
7
votes
2 answers

After using the unwrap method on entitymanager to get the native hibernate session do I have to close both?

I have code that looks like this. this.entityManager = AppFactory.instance().getEntityManagerFactory().createEntityManager(); this.hibernateSession = entityManager.unwrap(Session.class); try{ //do some queries using both entityManager and…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
7
votes
1 answer

Restarting the Entity Manager from Exception

How do I reset/restart a Entity Manager? Looking at Doctrines docs: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html#approach-2-explicitly I see that on an exception the Entity Manager…
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
7
votes
2 answers

When is a connection returned to the connection pool in a JPA application?

Is a connection only returned to the Connection pool in a JPA application if i call entityManager.close(); ? Can the connection backing the entitymanger change during its lifecycle? thanks in advance mojoo
7
votes
2 answers

Differences between Container Managed and Application Managed EntityManager

I have a problem to understand the differences between container-managed and application-managed entity manager? I would be very grateful if you can give me an example that illustrates the differences.
Wael
  • 183
  • 1
  • 2
  • 7
7
votes
2 answers

ZF2 and EntityManager (Doctrine)

I have a problem. I try to get the Entity-Manager without a Controller, but I found no way. At this time, I get the Entity-Manager like this: (Controller) public function getEntityManager() { if (null === $this->_em) { $this->_em =…
user1765334
  • 93
  • 1
  • 1
  • 6
7
votes
2 answers

WELD-001408 Unsatisfied dependencies when injecting EntityManager

I have @Stateless bean which implements two interfaces (remote and local). I have also added @LocalBean anotation for accessing bean with a no-interface view. @Stateless @LocalBean public class WeatherDataBean implements WeatherDataBeanRemote,…
7
votes
4 answers

EntityManager throws TransactionRequiredException on merge() in JBoss JSF bean

I've set up a JSF application on JBoss 5.0.1GA to present a list of Users in a table and allow deleting of individual users via a button next to each user. When deleteUser is called, the call is passed to a UserDAOBean which gets an EntityManager…
Kosi2801
  • 22,222
  • 13
  • 38
  • 45
7
votes
5 answers

entity manager doesn't have method getCriteriaBuilder()

I am introducing JPA2.0 in my application working on Oracle9i database and I added the libraries EclipseLink(JPA2.0) and created the entity classes but when I use javax.persistence.criteria.CriteriaQuery cq =…
Questionmark
  • 145
  • 1
  • 2
  • 10
6
votes
2 answers

Symfony2 subquery within Doctrine entity manager

I need to perform this query: SELECT * FROM (SELECT * FROM product WHERE car = 'large' ORDER BY onSale DESC) AS product_ordered GROUP BY type In Symfony2 using the entity manager. My basic query builder would be : $query =…
BobFlemming
  • 2,040
  • 11
  • 43
  • 59
6
votes
1 answer

How can the JPA recognize two classes with the same name but in different packages?

I use JPA and Hibernate for my project. I have two classes with same names but in different packages. They are: @Entity(name = "X_USER") @Table(name = "X_USER") public class User { and: @Entity @Table(name="Y_USER") public class User { I was…
kamaci
  • 72,915
  • 69
  • 228
  • 366
6
votes
5 answers

How to avoid overwriting of non-null values with null values?

I'm using spring MVC for receiving a JSON from client and automatically create an object from it. The problem is that the client doesn't send to server all the fields that are in the entity, but some fields are null and overwrite existing values…
Fabio
  • 644
  • 1
  • 8
  • 17
6
votes
2 answers

Hibernate java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction cannot be cast to org.hibernate.action.EntityInsertAction

I'm using Hibernate with an EntityManager. When I use Session session = (Session)entityManager.getDelegate(); session.flush(); session.clear(); I get java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction…
Stijn.V
  • 617
  • 2
  • 9
  • 23
6
votes
5 answers

javax.ejb.EJBException when persisting an entity

I have an entity called Medico which was created as an Entity Class from Database, hence I think the entity definition is failsafe here, nevertheless the definition is the following: @Entity @Table(name =…
camiloqp
  • 1,140
  • 5
  • 18
  • 34
6
votes
1 answer

EntityManagerFactory is closed, Hibernate

I have recently created a web service that uses a static method in Java to obtain a list of items from the database. The web service works perfectly and returns JSON back to the caller. However, it works only once. If you try to refresh or make a…
Robert Ruxandrescu
  • 627
  • 2
  • 10
  • 22
6
votes
1 answer

Can I have an entity that only maps to some columns of a table?

I'm making a database migration tool and am dealing with a source database that's very unwieldy. It's basically one giant table that has upwards of 40-50 columns. However not all of these columns are useful to me. I only want maybe a dozen or so of…
JMD83
  • 105
  • 1
  • 10