Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

spring mvc form submitting and many-to-one relation  RSS feed

Fabrizio Pia
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. Here my problem.

First object is named Persona.
Second object is named Societa. There is a relation many for Persona and one for Societa.
Societa has two properties, let's call them "des" and "desIndirizzo".

I've a spring form (<form:form>) with modelattribute="person" in order to change some person properties submitting such form.
Here an example:

From this form I need to change not only Persona's properties but also Societa's properties.

I think to write

This doesn't work.
I get "TransientObjectException: object is an unsaved transient instance - save the transient instance before merging:"
Anyway, in the browser I can see both the input texts correctly filled with the right values!

My questions are:
First: Because I set modelattribute="persona", I was expecting that "societa.des" is the same as "persona.societa.des". After a debug I see that "societa.des" is the same as "persona.des". Obviously this doesn't exists! Why? The only manner to work is to write

But in this case a new question arises:
Second: How can I relate the first <form:input> in order to submit the Societa's "des" property and the second <form:submit> to the Societa's "desIndirizzo" property?

Third: More in general, is it possible to change properties of a object (in my case Societa) from a form of a related object (Persona)?

I also wrote and registered a property editor like this:

Can anyobe help me please?
Thank you

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!