Hi all,

I 'm not using the tapestry-hibernate module.

I 'm using spring configured hibernate, tapestry-spring, and an open
session in view spring filter.

I can use BeanEditForm to create a new entity and save it, the problem is
when trying to modify an existing entity.

My problem is that during activation after submission I get an unmodified
instance of the entity from the database,
after that the beaneditform modifies the properties of that entity and
during validation when the DAO performs a criteria query
by name changes on the entity object are being flushed to the database.

I wonder how does the tapestry-hibernate module handles these  kind of
trouble,

Here is my code:

    @OnEvent(value=EventConstants.ACTIVATE)
>     public void activate(Long profileId) {
>         profile = this.profileDAO.load(profileId);
>     }
>
>     @OnEvent(value=EventConstants.PASSIVATE)
>     public Long passivate() {
>         return this.profile.getId();
>     }
>
>     @Log
>     @OnEvent(value=EventConstants.VALIDATE_FORM)
>     public void validate() {
>         try {
>             // validating if the new name already exists, if it does fail
> validation
>             this.profileDAO.getByName(profile.getName());
>
> this.profileForm.recordError(messages.get("error.profile.already.exists"));
>         } catch(ModelException me) {
>             // validation is expecting this exception, I know it's nasty
> but...
>         }
>
>     }
>
>     @OnEvent(value=EventConstants.SUCCESS)
>     public Object persistNewUser() throws ModelException {
>         this.profileDAO.save(profile);
>         return ListProfiles.class;
>     }
>

tried evicting the instance from the session on prepareForSubmit but then
(as the entity is lazy) beaneditform fails trying to set the properties.

Right now I 'll avoid using beaneditform for modification pages but I 'd
definitely prefer using it!

thank you so much,

cheers

Nicolás.-

Reply via email to