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
2 answers

Why my is EntityManager fetching outdated database object

Situation: App A (war running on a tomcat 7, rest interface for a web app) App B (java standalone, scheduled batch jobs loading data from a file into a database) In between a shared control table with a record per file. App A correctly persists new…
MMA
  • 13
  • 3
0
votes
1 answer

Hibernate AbstractMethodError

I am using the latest version of spring, hibernate and spring data jpa on a gradle project but I get an AbstractMethodError exception. here is part of the stack trace Caused by: org.springframework.beans.factory.BeanCreationException: Error creating…
Ashken
  • 69
  • 1
  • 10
0
votes
2 answers
0
votes
1 answer

JPA - Hibernate session is closed, but entitymanager works

Given the two line of code : entityManager.find(MyEntity.class, myId); ((Session) getEntityManager().getDelegate()).load(MyEntity.class, myId); The first instruction works fine, but the second one throws org.hibernate.SessionException: Session is…
fego
  • 309
  • 5
  • 20
0
votes
2 answers

execute a query using entity manager

I have a query to get the size of databases I have. I have written the following: @SuppressWarnings("unchecked") List results = (List) em.createQuery("SELECT sum( data_length + index_length ) / 1024 / 1024 \"DataBaseSizeinMB\" FROM…
Pegah
  • 672
  • 2
  • 13
  • 23
0
votes
0 answers

ORA-02291: integrity constraint (GOPI.SYS_C007099) violated - parent key not found with Hibernate

I have implemented a project in hibernate with MySQL which works fine. But my client wants it in Oracle 11g but the following code throws me this error. Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02291: integrity constraint…
Gopi Lal
  • 417
  • 5
  • 23
0
votes
1 answer

What Determines a persistence unit

I am creating a Java EE application and have setup my persistence using hibernate. Since I do not see this app being all that big I do not see the point in using EJBs so I created a PersistenceUtil class to manage my EntityManagerFactory. Something…
nerdlyist
  • 2,842
  • 2
  • 20
  • 32
0
votes
2 answers

Updating the ID of an instance in JPA

I am using JPA annotations(hibernate implementation), and i want to change the ID of an entity by merging it.There is any annotation or solution to avoid duplicating then removing the entity?
Ameur fahd
  • 21
  • 2
  • 5
0
votes
1 answer

Is it possible to make JPA throw an exception on a nontransactional write?

I am wondering if it is possible to make a JPA implementation throw an exception when a managed BO is modified outside a transaction of the managing entity manager. For example: BO someBO = new…
gchris
  • 1
  • 1
0
votes
1 answer

How get EntityManager in OSGI in Abstract Class?(like spring @PersistenceContext)

I tried create BaseDao and inject EntityManager to it. In Spring I was make this: public abstract class BaseJpaDao implements BaseDao{ protected Class entityClass; @PersistenceContext(unitName = "access") protected…
user5620472
  • 2,722
  • 8
  • 44
  • 97
0
votes
2 answers

How to use EntityManager in Singleton DAO from Servies

I'm new in JavaEE. I'm trying to make webapp using JPA with DAO and Service layer. Part of the task is not to use Spring and Hibernate. So i can use only JPA. As i understand, Service and Dao should be a Singletones. I should get EntityManager on…
Nem Exodare
  • 1
  • 1
  • 1
0
votes
3 answers

Why EntityManager's getDelegate() method does not return EntityManagerImpl as underlying object in Hibernate?

I am working on a migration of an application from Hibernate/OpenEJB/TomEE to Hibernate/JBoss and I have this exception at runtime: java.lang.ClassCastException: org.hibernate.internal.SessionImpl cannot be cast to…
Walid Ammou
  • 390
  • 1
  • 6
  • 21
0
votes
1 answer

Syntax Error in running a query in hql

I have a mysql table summarized as under: select * from transaction where workflow_id = 'A'\G *************************** 1. row *************************** transfer_id: 2 workflow_id: A amount: 552 status:…
archit
  • 69
  • 1
  • 2
  • 9
0
votes
0 answers

can't create entity manager, when add relationships

My classes: @Entity public class Contacts { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; private String login; private long token; @OneToOne @PrimaryKeyJoinColumn private UserInfo…
Igoryan
  • 53
  • 4
0
votes
1 answer

EntityManager connections stuck at 'Idle in transaction' after persist/commit

My EntityManager is persisting/committing data to a Postgres database no problem. However, the connections it makes get stuck at 'Idle in transaction'. Here's my code: public User create(User user) { if(logger.isDebugEnabled()) { …
ev0lution37
  • 1,129
  • 2
  • 14
  • 28