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

java persistence cross object method access

I am using an Employee and Company class as an example. In a Java persistence environment (Hibernate), when a bean is processing an Employee class with its' own Entity Manager, how can I call a Company class bean method when that object has its' own…
0
votes
2 answers

Java EE, Integer to User?

I have recently asked quite similar question here, but answer does not solve my new problem. I have two tables: User and Book, they are in ManyToOne relation. The Book table has attribute called user_id that connects both tables. Using Eclipse I…
Macjej
  • 117
  • 1
  • 10
0
votes
1 answer

EntityManager merge function setting non-set values of the obect to null

em.merge() updating uninitialized properties of the entity to null.. @PersistenceContext public EntityManager em; em.merge(invoice); in my database it is updating all the values which were set in invoice object, as well as it is updating…
Jitendra Yadav
  • 150
  • 1
  • 3
  • 16
0
votes
1 answer

How to subtract two fields in a one to many relation

I want to subtract a value from another field each time I add a new record this is my case:example soldeJours(from entity contrat) = nbjours (from entity contrat) - dureeAssistance (from entity assistance): Exemple : nbjours = 20 and when I add a…
user3419507
  • 117
  • 1
  • 4
  • 16
0
votes
2 answers

Spring JPA Multiple Datasources

I've seen similar questions on here but haven't been able to find an answer that truely works for me. I have 2 different datasources, each with its own transaction manager and entity manager factory. They are each defined in their own config…
0
votes
1 answer

Spring-batch Entity Manager becomes null after init

I'm currently implementing a Spring-batch that reads and writes to files BUT also needs to do CRUD operations on a database. I've tried to simply define an Entity manager in my xml configuration, and use it in my DAO class. However, right after the…
pegas
  • 111
  • 1
  • 9
0
votes
2 answers

Use two entity managers for one entity

The situation is the following: I have two databases Db1 and Db2, for which I have two EntityManagers em1 and em2 defined. Furthermore, I have the entity Person(int id, String name, Pet pet) mapped to the table persons(id, name) in the database Db1…
Rolch2015
  • 1,354
  • 1
  • 14
  • 20
0
votes
0 answers

persisting a bean failed and throw ValidationException [spring MVC]

I am trying to add a new count to the database and I should be sur that the username is unique, so I create a custom validator, but it throw an Exception : org.hibernate.AssertionFailure: null id in com.EChallenge.model.Compte entry (don't flush the…
ADA15
  • 86
  • 15
0
votes
1 answer

JPQL: why 'group by' does not work properly

Executing JPQL using hibernate 4.2.5: select c from Chargeback as cc join cc.customer as c group by c order by max(cc.created) Usecase: show customers with the latest chargbacks. produces org.hibernate.exception.SQLGrammarException: could not…
kadkaz
  • 123
  • 2
  • 7
0
votes
1 answer

How does a JBoss datasource failover handle failure in single transaction?

This is my connection detail in JBoss standalone.xml
0
votes
1 answer

entityMananger not working with Date parameter

Using EntityManager approach with Hibernate. Whenever using a date field query I am expecting it to look for date with complete date and time, but it only uses date not time. where cou0_.expiry_date>'22-Jan-16' spring config
0
votes
1 answer

Getting java.lang.ExceptionInInitializerError

I am creating a small program for a school exercise. I have no clue where I could have done anything wrong. Could someone please help me with this? I get this error when I run my test. I get the error at the this.emf = TestUtil.getEMF(); line. /* *…
Soundbite
  • 93
  • 4
  • 11
0
votes
0 answers

How to convert Map to Map

I used old JPA so that I can use code as below: JpaProperties jpaProerties; EntityManagerFactoryBuilder(jpaVendorAdapter, jpaProperties, persistenceUnitManager) Now it is deprecated so I want to change it to JpaProperties…
mikezang
  • 2,291
  • 7
  • 32
  • 56
0
votes
1 answer

IllegalAccessError in Java SE app with Weld implementation

I am trying to run a standalone app that has Weld implementation of CDI, and in that app I need EntityManager to work with Oracle database. When I run my app (via Weld main method), following is shown in cmd line: Exception in thread "main"…
Sarpy
  • 265
  • 1
  • 7
  • 18