Skip to content
Advertisement

Why am i getting a NullPointerException when trying to save an entity to a list?

Here is my database structure:

enter image description here

When I make a REST call to user_product with an intent to update the product value I keep on getting a null pointed exception. My assumption is that the problem lies in ServiceImpl though no matter what I change the error still consists.

My serviceImpl:

Eror log says that the problem is here:

I would appreciate any kind of clue where I might be messing up. Thanks in advance.

Edit:

My UserProduct class:

Edit2:

My UpdatedProduct class:

Advertisement

Answer

You would have to initialize the UserProduct class with an empty list, not null:

All the annotations were omitted for brevity.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement