Let’s say I have an app with many different entities, which do not have relations between each other. I would like to create a search that queries all of them, but returns a unified type, i.e: So my idea was to index the entities and put their values into one single index (with same index fields): As you can see,
Tag: hibernate
Update DB column which has null value in Spring boot JPA
I am trying to update in the database with the help of the Spring JPA and having an issue while doing it. I have an Embedded class in my entity. My entity class is : My Repository class is : Audit, Transfer and Beneficiary Details are my Emededded class and those are : My Controller class is: My error stack
Empty CLOB instead of NULL in Oracle CLOB field
Writing null string into Oracle CLOB field using Hibernate sometimes result in an empty CLOB instead of NULL in the field. Table STEP with a mix of varchar2, number and CLOB fields once was extended with a new CLOB field. and a corresponding field was added to entity All work as expected when non-null value stored. But when new record
Hibernate how to commit transaction even when exception pops up
i have a method in Service A And another method in Service B My problem is that when “repository.insertRandomValue()” throws ConstraintViolationException for example, then even tho it was caught in catch(), the thread ends with I have tried setting the propagation to REQUIRES_NEW and tried to set up transaction manager and GlobalRollbackOnParticipationFailure to false. I want it to simply ignore
Spring Boot Hibernate creates tables with wrong names
When I run my project, the Hibernate creates automatically tables with wrong names. I have two tables User and Role and also three classes: abstract class IdField.java: User.java class: and Role.java class: And Hibernate creates two tables with wrong names as id_field and id_field_roles: but I want table names as it is in @Table annotation like “user” and “role” Answer
How to create a JPA entity for a table that doesn’t have a Primary Key or Unique Key column
l have a table without a Primary Key or Unique Key column. I need to manipulate this table from the Spring application by using JPA and Hibernate. While I was trying to map this table’s entity, it fails because there’s no @Id mapping. I tried to make a composite id from all the entity properties to ensure uniqueness, but in
Accept Duplicate Entry Exception for Performance Benefits?
I am currently programming a news API. To fetch news I am using java to parse XML from a List of RSS Feeds (URLs) and write them to a mysql database. I am doing this at a regular interval i.e. every 5 minutes. As these news feeds often are identical or similar to the prior time fetching I currently get
Criteria API how to write = ANY(?1) expression?
I have a query that I want to translate to Criteria API. A query After java processes it (native sql query) the final query looks like this My Question is how to translate = ANY(?1) part to Criteria API? I see that any() definition is How to put array of values to it? I’m using PostgreSQL Answer You will need
@IndexedEmbedded on class containing other @IndexedEmbedded fields
I’m trying to manage hibernate search indexing on a class with a field mapped by @IndexedEmbedded on a custom @Embeddable entity. This entity also contains others @IndexedEmbedded fields in the @MappedSuperclass. These are the entities involved: And these classes: When running the application, Hibernate Search throws the following error: I’m running it with the following dependencies: Any suggestion on how
How to make a custom message from an already defined response on Spring
My API is returning me this: The problem is, I would like to, on the array that is represented by the second ID, return a error message, as there is no data in it. Something like this: My code is as follows: With this, I can’t seem to override the specific response, as it is an List of the Entity(Health).