I am using jdk 1.8 , hibernate and jpa in my project. And using specification/criteria to build my search query. I have a class A ( an hibernate entity) which has class B as an attribute. So, roughly, it looks like : and… My repository class looks like (roughly): } Most of the simple JPA queries are wor…
Tag: jpa
JPA ManToMany association and insert, retrieve data with Spring Data Repository
I need to setup many to many relationship between 2 entities, namely Project and Articles. The use case is a project that can be linked to many articles which are related. So does each article will be linked to various projects. I am using Spring data repository in my project and having trouble persisting and…
JPA With composite key non standard
I’m trying to do a JPA mapping for an existing database. I can’t really change the existing structure. I managed to make it works, but Intellij is telling me that some column doesn’t exist even if it works. So I don’t know if there’s a better way to do this or if it’s Intel…
How to annotate Map with JPA?
The app’s stack: Spring MVC, Spring DataJPA, Hibernate. There are three entities: student, tutor, theme. Theme: Student: Tutor: For save student-tutor-theme relationships i want use this table (PostgreSQL): How i can to annotate tutors and students fields in entities, for their content correct persists …
How to cascade delete set of enums in JPA?
I have the roles field in User entity: when I try to delete user with a query, the referential integrity constraint violation occurs, because user is referenced from User_roles table. How to solve this in any way? DDL for related table shows i.e. it doesn’t contain ON DELETE CASCADE clause. I need it be…
h2 database persists data but resets on application start
I have a basic test for an embedded database that I’m trying to get working for a java project. As it stands now I am able to save rows to the database with my entity repository object, and after the app finishes running, I can connect to the database with intellij and see those rows are still there. Bu…
Hibernate error “operator does not exist: bigint = character varying”
I’m using hibernate to read my database datas but i’m having a issue with the relationship of the tables when i run a query. And i don’t find the reason That’s the error: 2021-01-23 18:16:55.427 WARN 1192 — [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, …
Proper Lifecycle Order For Annotation Processing In Maven
I’m currently working on a java project where I need to generate and compile JPA metamodel classes as part of the build. I did some research and found an answer here: Generate the JPA metamodel files using maven-processor-plugin – What is a convenient way for re-generation? that seems like a reaso…
HIbernate “StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1”
When an existing user makes a request the method first deletes the oldest record before saving the new request. The code below works fine IF the requests don’t come in too rapidly (using an Oracle DB). Output: However, if the user were to submit requests in a very quick fashion, i.e. happy clicker, the …
config.ConfigurationException: Could not locate cfg.xml resource [hibernate.cfg.xml]
I am building a hibernate application that creates, modify, and query tables from a database. The project was running perfectly fine without having this error, when I try to run it now I got this error out of nowhere. The ‘hibernate.cfg.xml’ is placed in the ‘src’ folder as can be seen…