Dave Tolls wrote:How are you trying to print it?
Dave Tolls wrote:
It's a lot neater to remove the connection and having a view model on its own.
Nathan Milota wrote:
When I did a put request to update the owner, I was having it print the owners vehicles at the same time. It only prints [] every time, but it prints the endless list when I do a get request.
Nathan Milota wrote:Are you saying I did the hibernate wrong? I thought that was how the classes are supposed to be made.
Himai Minh wrote:How about setting up the bi-directional relationship using the setter in your Java code?
Himai Minh wrote:We usually have a class that perform saving the entities and building relationship among entities.
Here is an example : https://dzone.com/articles/introduction-to-spring-data-jpa-part-4-bidirection
You may want to do something like the RoleService's addRole method.
Dave Tolls wrote:And what is the exception?
There should be something in your logs.
I would also say, yes @ignoreJson works, but you now have a model that is trying to be all things to all people.
Nathan Milota wrote:One of my vehicles had a null owner so it threw an exception.
Nathan Milota wrote:
Do you have a better suggestion than the @JsonIgnore?
Dave Tolls wrote:
Nathan Milota wrote:
Do you have a better suggestion than the @JsonIgnore?
In my first post.
You have two models.
One for the database (your current model) and one for the various ways you display that data.
They really are two different models.
Consider Paul's rocket mass heater. |