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
EntityManager merge() causes duplicate rows
I'm getting some very odd behavior with EntityManager.merge(). Here's what is happening. I have a REST API setup with Spring MVC, Hibernate, and JPA to insert, update, and delete items from a MySQL database. Both the insert and update functions use…

Graham
- 5,488
- 13
- 57
- 92
0
votes
0 answers
How to use LazyLoading with EntityManagerFactory
I'm trying to use EntityManagerFactory like this:
@Service
public class UserServiceImpl implements UserService {
@Autowired
private EntityManagerFactory entityManagerFactory;
@Override
public User getByID(long id) {
Session session =…

Tom Wally
- 542
- 3
- 8
- 20
0
votes
1 answer
How to define the constructor of an EJB3 session bean
I'm creating an EJB3 module which tries to respect a specific facade/implementation design pattern. My facade should be totally EJB free.
I have 2 classes in this module: an entity bean and a session bean, which is the manager of this entity. The…

Pierre Duplouy
- 2,415
- 5
- 23
- 24
0
votes
1 answer
Can not remove an entity through EntityManager#remove()
I am using JPA.
I have the following code:
@Entity
public class NucleoFamiliar {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String nombre;
private Date fechaCreacion;
@ManyToOne(fetch =…

Gabriel
- 27
- 2
- 6
0
votes
1 answer
Hibernate NoSuchFieldError: INSTANCE
I'm trying to integrate Hibernate Search with Spring Data JPA, so I wrote a sample code to test it.
@PersistenceContext
EntityManager em;
@Override
@Transactional
public List findAll() {
FullTextEntityManager fullTextSession =…

Jakub Pomykała
- 2,082
- 3
- 27
- 58
0
votes
1 answer
Configuring Hibernate Search with EntityManager
I want to add Hibernate Search to my project, I write sample code like this to test it.
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("pu");
EntityManager em = entityManagerFactory.createEntityManager();
…

Jakub Pomykała
- 2,082
- 3
- 27
- 58
0
votes
0 answers
subsequent save in JPA transaction
I have a service class the injects two JpaRepository classes: organizationRepository and stateRepository. In the service method I need to perform two transactions:
@Override
@Transactional
public Status createOrganization(@ResponseBody Organization…

tblack06
- 35
- 2
- 9
0
votes
1 answer
h2 jpa delete method not working java
im trying to test this method to remove an entity from the h2 database:
public boolean delete(T entity) {
if (entity == null) {
throw new IllegalArgumentException();
}
boolean ret = true;
EntityManager em =…

Pedro Silva
- 25
- 6
0
votes
0 answers
Deadlock while syncronizing Spring entity manager query
I'm developing an application using Spring which directs the DB using entity manager with @PersistenceContext injection. the application is executed in multiple threads, each in its own @Transactional scope.
As part of the thread process it should…

moshe
- 439
- 2
- 6
- 16
0
votes
1 answer
What is the difference between an EntityManagerFactory and an EntityManager
I'm reading through the JAVA EE7 Persistence chapter, and all I see is that you need to create a EntityManagerFactory in order to create an EntityManager.
All the method calls seem to be done by the EntityManager, so why is there a need to create a…

BartKrul
- 577
- 1
- 8
- 21
0
votes
0 answers
Derby Delete Error
Both my tables are bound to their respective JTables. I have the entitymanager and all the other stuff.
I can insert into tables, but when I try to delete a record, it comes back to say that the record cannot be found or does not exist. Here's my…

GipsyD
- 206
- 1
- 3
- 16
0
votes
2 answers
Deleting data from database using EntityManager causes violating referential integrity
I am trying to remove data from by database, using the javax.persistence.EntityManager. This is a class diagram of the specific extract of my application:
I have a model class WorkOrder, which contains a Specimen. I am able to create new WorkOrders…

John
- 795
- 3
- 15
- 38
0
votes
1 answer
Standalone JTA 1.2 and Hibernate: JPA not rolling back?
I'm using the "JBoss quickstart" tutorial described here.
It demonstrates the use of distributed transactions including JPA in standalone applications.
I've downloaded the code, runs fine, all test cases are green.
It contains the following test…

geert3
- 7,086
- 1
- 33
- 49
0
votes
2 answers
How to open an entity manager after a close()
I'm working on a class that inject an entity manager in my dao classes
but I when I close the entity manager I can't open it again
This is the class
public class EMinjector {
public static EntityManagerFactory eMF;
public static EntityManager…

Mohamed Elalami
- 149
- 2
- 12
0
votes
2 answers
entity manager not correctly injected by spring and gives java.lang.NullPointerException
I'm a newbie at using frameworks in JAVA EE
so when I'm trying to call a method of the entity manager
it throws a java.lang.NullPointerException
so I want to what I wrote
this is an example of my dao implementation
@Repository
@Transactional
public…

Mohamed Elalami
- 149
- 2
- 12