I have a Java application that connects to a Postgres DB using EclipseLink. My problem is that database triggers are triggered before the Java/EclipseLink transaction is completed causing the data to be incorrect. Example: There is a trigger to update a order_logs table every time there is an insert or update on the orders table. Problem: When a setter() method
Tag: orm
Hibernate: How to distinguish two uni-directional relationship and one bi-directional relationship?
in this answer, the author said: Take an example of two entities mapped without declaring a owning side: From a OO point of view this mapping defines not one bi-directional relation, but two separate uni-directional relations. 1.My first question is: Why it is not a bi-directional relation? Docs Oracle: In a bidirectional relationship, each entity has a relationship field or
What is difference between transient state and removed state in JPA?
I have a question about entity states in JPA. I’ve read some article about entity states in jpa and my understanding about them is that: a transient object is a newly created object that hasn’t been associated with Persistence Context and does not represent a record in database. and when we remove an object, it doesn’t have any association with
select new (JPQL Constructor Expression) in jpa/hibernate causes “lazy” loading for each row
Recently I found no obvious behaviour when using ‘select new/constructor expression’ in jpa/hibernate. It uses kind of lazy loading for each entity in each row in result set what is not efficient. Test example First case we issue a query using select new technique: This issues one query to fetch only ids of e1 and e2 and then more queries
Update statement is no query?
How do I define the update statement in the orm.xml. I have it as a named-query and everything works, but my teacher said that an update statement isn’t a query. I have tried a native query, but that wasn’t working. ORM-Type: Update Statement: Answer The term “query” is used rather ambiguously. Some people interpret it literally as “asking for information”,
Java ORM vs multiple entities
I have a class Health Check – as part of the class I record how many parasites are seen (enum NONE, SOME, MANY) and also the location of the parasites (enum HEAD, FEET, BODY). Two ways this could be done: METHOD 1 Health Check Parasite Or I could have: METHOD 2 Would method 1 require @Entity on parasite class and
NamedQuery returning entities with null fields
defined entity with namedquery as SELECT mdl FROM tbl_slots mdl where mdl.test_date between :dt and :dt order by mdl.test_time asc if used * instead of mdl in query, JPA gives error unexpected token: * if mentioned the column names in select statement it returns entities with respective fields populated with expected values [{ “srNo”: 1, “testDate”: “2021-Dec-30”, “testTime”: “09:00-10:00”, },{
How can I batch the audit table inserts using the Hibernate Envers ValidityAuditStrategy
I’m using Hibernate envers for auditing, and most of my tables are performing batch inserts just fine. However, on one of my entities I have an audited collection, which seems like it doesnt want to batch. MyEntity: (Not sure if this is important, Im using postgresql). In the logs I see 1000s of these statements in a loop Doing some
auto changing data with Hibernate
I have problem with Hibernate. I have next method: This method should assign user on task and send message to kafka consumer with TaskBeforeUpdate and TaskAfterUpdate. But I have problem when I try to assign user, my BeforeUpdateTask change all his fields to TaskAfterUpdate. And this dont work, but i dont know why he is change all values. Answer The
Error while saving user to h2 using springboot
I’m trying to register a user entity through an API and add it to “users” table in my local dB. I keep getting the error mentioned below. I am sending a POST request with the following body: It states the “NULL not allowed for column “ID”” but I don’t understand why ID is getting a null value. The User class