In a form; I have a select box defined as:
<s:select name="propertyOfModel.id" list="myListOfValues" listKey="id"
listValue="description" />

In the model I have the propertyOfModel annotated as @ManyToOne as
follows:
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="PROPERTY_ID",nullable=true,insertable=true,updatable=t
rue)
public PropertyOfModel getPropertyOfModel() {
  // ...
}

Now the form gets submitted to a Struts2 Action which implements model
driven and uses the prepare() method to setup the entity model before
setting the values from the form by querying the service tier for the
object by ID.  The problem is that when the interceptor sets the values
on the model for propertyOfModel.id; if the original propertyOfModel
object was null; then there is no issue but if the object wasn't null
when queried from the database, then I get a transient exception because
it is as if the original object is having it's primary ID changed.

How have others worked around this?  One option I explored was for
setting propertyOfModel object by it's id; I simply set a property on
the action called propertyOfModelId and then use the ID to query the
object from its associated service and then set the object instance or
set to null if ID was null.  

Any other alternatives?

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to