Questions tagged [hibernate-entitymanager]

Hibernate EntityManager implements the programming interfaces and lifecycle rules as defined by the JPA 2.0 specification.

Hibernate EntityManager implements the programming interfaces and lifecycle rules as defined by the JPA 2.0 specification. For more informatio refer the link.

288 questions
1
vote
0 answers

EntityManager per User in a tomcat web application

I have an uncommon requirement in my web application. It is a normal tomcat, spring, hibernate application, but each user want to select the DB to work with directly after login. After a successful login the user get a drop down list with available…
1
vote
1 answer

Arquillian and Flyway using different versions of H2 in-memory

I'm trying to create a JPA-helper, which will eventually be turned into a jar and used in other projects. I want to add Integration tests to this project, so I've added a TestEntity and TestService class (these refer to a simple TEST table in the DB…
Chris
  • 3,328
  • 1
  • 32
  • 40
1
vote
0 answers

I am trying to DB connection to sql server using struts and hibernate but got error in Listener class

public void contextInitialized(ServletContextEvent arg0) { EntityManager em = null; try{ TransactionManagerServices.getTransactionManager(); System.out.println("In Listener"); emf =…
1
vote
3 answers

Error creating bean with name 'entityManagerFactory, can not run App properly

My App in SpringBoot can not run properly. Tried to change dependencies, classpath, deleting and reinstall whole folder with hibernate in local .m2. I'm making Spring boot security login system in my app, before that, everything was alright. change…
1
vote
1 answer

entityManager.createQuery() throwing NullPointerException

I'm migrating an old system to a new platform (Java / Spring Boot), and am re-writing a complex query in HQL (I've reviewed the options, and feel that writing in HQL/JPQL is preferable to the JPA Criteria Builder API / derived queries). To create…
1
vote
0 answers

How to fix 'Unable to resolve property: id.element' Hibernate error when fetching with an @EmbeddedId

I have a method throwing the next error when querying a list of Hibernate entities while also fetching with a Join a OneToOne relation, having the child an @EmbeddedId . org.springframework.orm.hibernate3.HibernateSystemException: Unable to…
p4x
  • 384
  • 1
  • 5
  • 16
1
vote
1 answer

Does JPA Entity store reference to Entity Manager?

@Entity class Employee{ @Id String name; int age; String gender; } I'm using the above entity object as key in Hashmap: Employee e1 = new Employee("abc",23,"M") Now if I create a new entity with same id and persist it: @Autowired EmployeeDao…
1
vote
0 answers

Is calling Hibernate Session.save() from within Entity an Anit-Pattern?

I've recently come across a legacy code base that uses a slightly dated version of Hibernate. The codebase uses the good old [HibernateUtil][1] pattern. One thing I find really odd is that every entity class has a create(),read(), save(), and…
1
vote
0 answers

Spring Boot 2.0.x - @Configuration class @Autowired entityManagerFactory NullPointerException

I used Hibernate session to query data from MySQL. I used JPA EntityManagerFactory to get Hibernate SessionFactory: @Configuration public class DatabaseConfig { @Autowired private EntityManagerFactory entityManagerFactory; @Bean …
trimaximus
  • 11
  • 4
1
vote
1 answer

setParameter issue with createNativeQuery of entityManager JPA

I want to apply parameter binding to the dynamic native query where the column name which i am fetching i will be passing that dynamically from the UI.(say emp_id in this case). Following is the sample java code snippet, org.hibernate.Query…
greenhorn
  • 594
  • 6
  • 19
1
vote
2 answers

How to get the data in query(search result of hql)?

I am a novice to use jdbc and I have some problems. I use hql to search data in MySQL, and the result is Query type. I don't know how to get the data from the "Query".This is my code: final String hql = "select app.appkey,app.type from " +…
Shuitian Wei
  • 81
  • 11
1
vote
0 answers

Change database schema of entitymanager during runtime based on logged in user

I have read many questions and answers about dynamic implementation of EntityManager with different schemas. I found also a solution using alter database session to set current schema (see below). ALTER SESSION SET CURRENT_SCHEMA= "SCHEMA_NAME" As…
Premsj
  • 11
  • 2
1
vote
0 answers

MySQL GET_LOCK() and RELEASE_LOCK() WITH JAVA8

release_lock is returning a 0 -- which according to the documentation means the lock was created by another session. However, in the code we are creating a single session which is establishing the lock, doing multiple transactions of work, and then…
Byg Eynst
  • 33
  • 1
  • 7
1
vote
2 answers

How to use JOIN using Hibernate's session.createSQLQuery()

I have two Entity (tables) - Employee & Project. An Employee can have multiple Projects. Project table's CREATOR_ID field refers to Employee table's ID field. Employee entity does not maintain any reference for Project - but Project entity has a…
javauser71
  • 4,979
  • 10
  • 27
  • 29
1
vote
0 answers

hibernate5 JpaRepository save not saving entities in bidirectional relationship

I'm upgrading Hibernate4 to Hibernate5 (Spring 4.3.7) (Spring-data-jpa 1.11.1) and facing the problem with saving of bidirectionally associated entities save using JpaRepository.save(ownerObject). Here are my entities :- DataType (Owner Entity) :-…