Re: Submitting values for null associations

2014-02-11 Thread francois meillet
The entity User needs to have a Job's instance when you construct your model. François On Tue, Feb 11, 2014 at 2:56 PM, ChambreNoire a...@tentelemed.com wrote: Hi, I have a form which can flip between edit and view modes. Its fields share a common CompoundPropertyModel which in turn

Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
Yes I'm aware of this but the problem is I'm reusing the same AbstractEntityModel (effectively a LoadableDetachableModel that loads from the db) for the edit mode and the User instance in the db has no Job instance (yet). I could always re-build a Model using the unproxied User instance when I

Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
I forgot to mention, the reason I don't systematically make a new Job instance is that when saving the form hibernate creates a new Job instance which is effectively empty if no Job details have been input. Chambre -- View this message in context:

Re: Submitting values for null associations

2014-02-11 Thread francois meillet
As Hibernate save a new Job instance when you save the User if the relation is empty why don't you load the job (with an eager fetching strategy) when you load the user ? François On Tue, Feb 11, 2014 at 3:22 PM, ChambreNoire a...@tentelemed.com wrote: I forgot to mention, the reason I don't

Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
Why would that make any difference? A null Job is still a null Job. Unless I'm missing something... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664371.html Sent from the Users forum mailing list archive at

Re: Submitting values for null associations

2014-02-11 Thread francois meillet
You use cascade=all on the job relation. When job is created, it should have at least one non-empty property. Job's instance is null because it doesn't have any non empty property. François On Tue, Feb 11, 2014 at 3:59 PM, ChambreNoire a...@tentelemed.com wrote: Why would that make any

Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
I'm afraid I still don't see it. I think I'm just going to have to use a nested model at the form level and rebuild it whenever I toggle viewing/editing mode. So I'd build a new Model() from the unproxied User when switching to edit mode and build a new AbstractEntityModelUser(user.id, User.class)

Re: Submitting values for null associations

2014-02-11 Thread Marios Skounakis
I'm not sure there is a very clean solution. When switching to edit mode, you could set the User's Job to a new Job instance if it is null. You don't have to reattach/reassign any form components if you simply update the AbstractEntityModel's object. I.e. you either do