The EntityManager is the representation of a PersistenceContext, allowing a user to manipulate data pulled from a database.
Questions tagged [entitymanager]
1802 questions
0
votes
1 answer
Playframework: JPA EntityManager merge function fails - does not use subjects member variable values
Before I describe the problem, let me explain that I'm using Playframework 2.4.4, with Hibernate 5.0.5 and using the pure JPA methods, i.e., I don't have access to the Hibernate 'saveOrUpdate' methods, but must use either merge or persist. Also, as…

svaens
- 649
- 7
- 23
0
votes
1 answer
JPA: EntityManager flush() method behaviour
When I do following:
em.persist(entity);
em.getTransaction().commit();
After execution of second line,I can see SQL Insert in traces and a row in DB inserted. But when I do:
em.persist(entity);
em.flush();
em.getTransaction().commit();
In this…

Mandroid
- 6,200
- 12
- 64
- 134
0
votes
1 answer
Unable to lookup JNDI name when building entity manager factory with Hibernate as persistence provider
my persistence.xml:

FuSsA
- 4,223
- 7
- 39
- 60
0
votes
1 answer
Unable to lookup JNDI name
hi i'm using netbeans+glassfish
i'm trying to run this code:
i only create DB without any table ( by running this code i want to create tables and persist my object)
public static void main(String[] args) {
SmartphoneService ss = new…

FuSsA
- 4,223
- 7
- 39
- 60
0
votes
2 answers
JPA: EntityManager delete/update
When I call EntityManager's update or remove method, I first need to make the entity managed by calling find(). But it means double trip to database.Am I doing it wrongly or is it the only way?

Mandroid
- 6,200
- 12
- 64
- 134
0
votes
2 answers
Spring Data @ManyToMany update and create entity
I think it's very common problem with saving new entity with exisitng entities (@ManyToMany relation)
Place model
@Entity
@Table(name = "places")
public class Place implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
…

Jakub Pomykała
- 2,082
- 3
- 27
- 58
0
votes
0 answers
java.lang.UnsupportedOperationException: LOCK_ALL is not implemented for this cache
I am getting error java.lang.UnsupportedOperationException: LOCK_ALL is not implemented for this cache when executing below query. Using Hibernate and Spring MVC. I have done the PofSerializer class for my entity and mapped same in my cache.…

user2578580
- 1
- 3
0
votes
1 answer
How to order by computed column in new dto query
I have this query:
em.createQuery("select new SomeDto(some.name, " +
"(select max(other.weight) from Other other where other.someId = some.id) as otherWeight" +
") from Some some order by otherWeight")
.getResultList();
Which does not work because…

NoUsername
- 693
- 6
- 20
0
votes
2 answers
JPA - Lazy Loading - LazyInitializationException - When Not accessing child collection
I am building a project with Stripes, Spring, JPA & Hibernate amd have an object with a many to one child collection. I have set the loading as Lazy
eg.
@OneToMany(cascade = CascadeType.MERGE, mappedBy = "paperOffering", fetch =…

Mark
- 1,509
- 1
- 15
- 28
0
votes
1 answer
virtual column field not updated after entityManager.merge()
I have below scenario while updating Person entity..
My initial entity:
firstName:x
preferredFirstName:y
name:y (this values is calculated in the database. the logic is if preferredFirstName has value then name = preferredFirstName, else name =…

rohith
- 733
- 4
- 10
- 24
0
votes
1 answer
Is it possible to find all available EntityManager properties?
I need to use multiple persistence units with different properties (in my case MySQL and Oracle database). In persistence.xml I define two different "persistence-unit"s and list only the entity classes there.
Properties could be set in…

Andreas L.
- 2,805
- 23
- 23
0
votes
1 answer
Inject @Named , @Stateful to @Singleton EJB
Is there any way to inject @Named bean to Singleton?
Here's the class that needs to be injected
@Named
@Stateful
@ConversationScoped
public class PlaySessionBean implements Serializable {
@PersistenceContext(unitName = "test-persistence-unit",…

Willy Pt
- 1,795
- 12
- 20
0
votes
0 answers
EntityManager.merge() not updating the child entities
I am trying to update the child entities using entity manager merge().My entities are:
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
…

user1188867
- 3,726
- 5
- 43
- 69
0
votes
1 answer
Spring 4 and hibernate 4 EntityManager instance is null
Whenever I try to use the entitymanager using the @PersistenceContext annotation, it is null.
i'm using glassfish server 4.1 : I get this infos in the log :
Infos: Building JPA container EntityManagerFactory for persistence unit …

daley
- 177
- 1
- 2
- 9
0
votes
1 answer
IllegalStateException: Specified field type EntityManager is incompatible with resource type EntityManagerFactory
I had a problem when I tried to autowire entitymanager into my DAO classes. I think I've configure it properly with @PersistenceContext, but the error still exists.
Thanks in advance.
my DAO
@Repository
public class UserDAOImpl implements UserDAO{
…

Gnostikoi
- 117
- 2
- 3
- 12