I’m using in a apache-tomcat-8.0.41 web service. In this link they say “Hibernate EntityManager implements the programming interfaces and lifecycle rules as defined by the JPA 2.0 specification” https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html_single/ But it’s for t…
Tag: jpa
@PreUpdate doesn’t save parent object when it’s updated
I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications(childrenLastModifiedDate). To maintain that, I added method: Here is the problem. It’s not always invoke when the child is saved. Lo…
Need to insert 100000 rows in mysql using hibernate in under 5 seconds
I am trying to insert 100,000 rows in a MYSQL table under 5 seconds using Hibernate(JPA). I have tried every trick hibernate offers and still can not do better than 35 seconds. 1st optimisation : I started with IDENTITY sequence generator which was resulting in 60 seconds to insert. I later abandoned the sequ…
Spring data JPA: how to enable cascading delete without a reference to the child in the parent?
Maybe this is an overly simple question, but I am getting an exception when I try to delete a user entity. The user entity: And I have an entity class which references a user with a foreign key. What I want to happen is that when the user is deleted, any PasswordResetToken objects that reference the user are …
Which collections are supported by Hibernate @ManyToMany annotation
I used @ManyToMany annotation on a Set and it worked fine. When I used ArrayList instead of Set it throws exception: org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: com.kaushik.winnersoft.data.Student.enrolledCourses Is ArrayLis…
org.hibernate.QueryException: JPA-style positional param was not an integral ordinal
I have the following JPQL request; But it prints following error: What the reason of my problem? Answer You have no whitespace between lines also check that the ?3 param is not empty list
invalid column name in namedNativeQuery in spring-hibernate-jpa
I have very simple Entity class and two native query in it . QUERY1 is run right and return PersonEntity , but the QUERY2 return exception (invalid column name !!! but my column name is exactly this) ; MY ENTITY CLASS : DAO CLASS : EXCEPTION : Table Describe Answer The problem is that your second query return…
JPA many-to-many relationship causing infinite recursion and stack overflow error
I’m working on an EclipseLink project in which one user can “follow” another as can be done on social media sites. I have this set up with a User entity (referencing a table called users) which has a list of “followers” (users who follow that user) and another list of “foll…
JPA/EclipseLink Error in Creating Tables
I am trying to create a table using EclipseLink. The java class being used is :- The relevant persistence xml in question is as follows:- We use the standard method is by implementing the EntityManagerFactory as :- However I keep getting the following errors :- EL Warning]: 2017-04-07 14:04:53.768–Serve…
Return custom object from Spring Data with Native Query
My question is based on another post. How can I achieve the same with a native query? Native queries do not allow JPQL thus do not allow new instances either. My POJO. My database table contains coordinates for cities perimeter, so there are three columns: city_name, latitude, longitude. Each city contains lo…