Skip to content
Advertisement

Hibernation error many to one. How to create it correctly?

I’m trying to create a many-to-one base, but when adding via .jsp gives an error, via H2 console everything adds ok!

Please help me understand how to properly create a many-to-one relationship. It seems I got it wrong somewhere, or the problem is in the .jsp itself. Because as I said via the H2 console everything works well!

Thank you in advance!

My Group:

JavaScript

My group controller:

JavaScript

My Team:

JavaScript

My TeamController:

JavaScript

My .jsp form:

JavaScript

Exception:

JavaScript

Advertisement

Answer

You should make it a bidirectional relation, should add a @OneToMany annotation to your Group entity, like so:

JavaScript

then, if you type just Group’s id in your jsp input, you have to create a Converter (id->Group), i.e.:

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