Skip to content

Tag: jpa

Getting null value reference in One to Many mapping in Spingboot

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

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

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,

@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

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