I am trying to implement ONE-to-MANY mapping among two entities. In here designations have a location and a location have many designations. Once I added the designation it mapped fine, but it update the location table with null except id. Here I’m using the Microsoft SQL server. Application Properties DesignationMaster LocationMaster Service class of Designations Controller class of Designation I
Tag: jpa
Get records which are last updated in n minutes in jpa
I am working on a jpa query which requires to fetch all the records whose last updated time is more than 15 minutes My query goes like I will be passing the minutes dynamically ie in my jpa This does not work. I want to pass the minute dynamically. Can someone please help me with this Answer You can use
Multiple @ElementCollection fields with discriminator?
I want to have a Game entity that has two List of player IDs stored as Longs This is my table: game_player_team game_id player_id team 1 1 H 1 2 H 1 3 A 1 4 A And this is how far I got modeling the Game entity I can’t work out how to get only the player_id’s for the
Unidirectional OneToOne cascading from Child to Parent
I’m in the process of migrating a Hibernate 3 application to Hibernate 5.2. We have a couple of one-to-one unidirectional mappings with cascading (which we can’t make bidirectional because the parent can’t know anything about the other entities). The following (simplified example) worked fine in the latest Hibernate 3.x and latest Hibernate 4.x, but started running into ConstraintViolationExceptions in Hibernate
while deploy in tomcat – No bean named ‘entityManagerFactory’ available
While deploying project to tomcat I got this error,but with sts ide all works perfectly. spoiled my 2days 🙁 . pom.xml Answer A version updation of hibernate worked for me!
How to not hardcoding image extensions in Java?
How to not hardcoding image extensions in Java? Above is my code. In the case statement, I have listed strings as hard-coded as jpg, jpeg…. This code is not flexible, so I’m sure there must be a better way. I’d appreciate it if you could give me a solution that I’m not aware of. Answer As one of possible ways,
Java spring hibernate JPA @ManyToAll findAll() slow on large data, many subqueries created
I have 2 classes, Aircraft and Operator, with a one to many relationship from Operator to Aircraft. A findAll() call on the Operator table, which has around 10k rows, from the JPA Repository runs quickly, in just a few seconds, but the findAll() call on the Aircraft table, which has around 65k rows, sometimes takes minutes to execute. Also, I’ve
@Column settings in case of externally managed database schema
When externally managing the database schema (e.g. with Liquibase), in addition to specifying the Liquibase changesets, you have to help Hibernate understand your data structure using JPA annotations. While some annotations concern higher level abstractions of the underlying data like @Embedded or @OneToMany, other lower level annotations, such as @Column(length = 255, nullable = false), seem only to represent what
JPA integrity constraint violated – parent key not found when trying to save entity with JoinColumn
I am trying to save a User Entity with Roles under it. It seems like since the roles do not have their user id foreign key set it fails to save, is there a way to tell jpa to set the role’s user id after it saves the user but before it saves the user’s roles? Or will I need
CriteriaBuilder slows down during ~15000 executions
Spring 5.3 with Hibernate 5.6: I am experiencing some performance issues after rewrite/migration from Hibernate Criteria API to JPA CriteriaBuilder for a findByCriteria method that runs ~15k times during startup of my app. Normally, this would take maybe one minute using Criteria API but when I have the JPA code run, all is good until ~9k iterations (which takes about