Questions tagged [entitymanager]

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

1802 questions
0
votes
1 answer

Silex Doctrine "The EntityManager is closed" after Doctrine Exception

I am registering Doctrine in Silex in this way: // Doctrine $this->register(new DoctrineServiceProvider(), array( 'db.options' => $this['config']['doctrine']['db.options'] )); $this->register(new…
cybtow
  • 157
  • 14
0
votes
1 answer

Can you persist many entities of a variety of classes using a single javax.persistence.EntityManager?

Let's say you have table table1 and table table2. I am using Springboot with hibernate JPA. I declare the EntityManager object as below using @Persistencecontext annotation @PersistenceContext private EntityManager em; And then I want to loop…
Tisha
  • 827
  • 3
  • 11
  • 34
0
votes
0 answers

HSQL default identity 0 conflicts with jpa entities with identity int id defaulted to 0

I have a JPA entity with: @Id @Column(name = "id", columnDefinition = "INT") @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; and using EntityManager.merge by default For testing I'm using HSQL that default its "auto increment"…
Aviram
  • 553
  • 1
  • 8
  • 21
0
votes
1 answer

EntityManager is closed whenever I return like @PersistenceContext protected EntityManager entityManager;

I get the Entitymanager like; CRUD(){ @PersistenceContext protected EntityManager entityManager; public EntityManager getEntityManager() { return entityManager; } } And in my stateless EJB;I use…
Ratha
  • 9,434
  • 17
  • 85
  • 163
0
votes
1 answer

Hibernate EntityManager is getting closed, in wildfly 10

I use container managed JPA where inject the EntityManager instance. With the injected entitymanager instance, when I use find() method it says entity manager is closed. I use wildfly 10. How can I overcome this issue? What I do wrong here? I…
Ratha
  • 9,434
  • 17
  • 85
  • 163
0
votes
1 answer

EntityManager auto wiring if I am using crudrepository

I have an interface that implements crudrepository. I am using @Query annotations. I really need an entitymanager to build a native query. What should I do? Should I tear down the interface implementing crudrepository and extend from…
Julie
  • 179
  • 2
  • 13
0
votes
0 answers

set timeout query on entityManager

How I can configure the timeout for persiste() query of EntityManager ? I would like that the insert request never takes more time than 1 second! Here is the code of DAO service : @Service @Transactional public class DAOServiceImpl implements…
0
votes
1 answer

javax.transaction.SystemException: Illegal state (Expected: PrePrepared). BEA1-0A15322BC6A35D331713

I am upgrading entity beans in our application from EJB 2.0 to 3.0 version. I am using openjpa version 1.2.2 on weblogic server(10.3.0) and transaction type will be JTA. I am facing the below error while committing the transaction post persisting…
Niru
  • 80
  • 1
  • 6
0
votes
1 answer

SpringMVC + JPA + Cannot find the declaration of element 'persistence'

I am getting the " Cannot find the declaration of element 'persistence' exception. I tried the solution given at OpenJPA 2.1.1 - Cannot find the declaration of element 'persistence' but it did not work. Below are the details of my project. I have…
Ash Ash
  • 443
  • 4
  • 7
  • 15
0
votes
0 answers

How to change JPA connection on the fly

I'm using JPA for a desktop software. The end user needed a frame to change the Database connection dynamically (on the fly) by changing the persistance.xml data. I've tried using below code (which I found here) and modified but so far unsuccessful…
Thanuj
  • 139
  • 2
  • 12
0
votes
1 answer

What can be a reason for persist()/merge() to create two rows in database?

I am starting my second project in JavaEE and created simple singleton bean to init some data in database for future debug purposes. However, I am stuck at strange problem - persist method(as well as merge) creates two rows in database. And all I do…
newfolder
  • 108
  • 2
  • 9
0
votes
1 answer

Hikari configuration in xml for Master/Slave Datasources

Presently I have a datasource configured using Hikari in my applicationContext.xml. I want to configure in the same xml file for a master/slave kind of datasource. Also how do I establish a new entity manager factory in the same ? My…
The-Proton-Resurgence
  • 808
  • 1
  • 13
  • 28
0
votes
0 answers

Hibernate Transaction working slowly

I had a piece of code which was inserting data into 4 tables in DB one record at a time. The data comes from a file which has around 11K records on an average. With this code the complete processing is getting done in 10-15 min. for (final…
Rachit M Garg
  • 263
  • 4
  • 19
0
votes
2 answers

How to implement generics using JPA/hibernate EntityManager and EJB3.0?

I have an slsb holding my business logic, how do I use generics to change the following three methods into one generic method ? The first two are the same db, the third is a different database. Also do the methods require further annotation in…
NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
0
votes
1 answer

EntityManages NullPointerException, eclipselink + tomee + Jersey + Derby

I am new to JPA, EJB and REST topic and wanted to make some simple crud app. When I use EntityManagerFactory I get entities from Derby but problem starts when I want to use transactions for persisting objects. When I try to inject EntityManager I…
Jakub_R
  • 26
  • 4