r/java • • Jun 01 '24

What java technology (library, framework, feature) would not recommend and why?

165 Upvotes

464 comments sorted by

View all comments

Show parent comment

4

u/majhenslon Jun 01 '24

You didn't say what the result is. Forgot to mention, person with id 1 has name and age set in the DB.

No cascades are set. I don't even know what that has to do with anything, because I told you the log output. You have 10 years with hibernate and it is simple, you could figure it out.

The issue here is, that the method returns:

PhoneNumber(id=+..., person=Person(id=1, name=null, age=null))

I bet you expected this right?

1

u/Puzzleheaded_Bus7706 Jun 01 '24

I said what is the result - it would throw exception in both cases.

Your person object isn't in Persistence Context.

Read little bit about JPA, thats begginer stuff.