Skip to content
Advertisement

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

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”, },{

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

Advertisement