You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vinicius Carvalho <ja...@gmail.com> on 2006/08/19 16:20:48 UTC

Tapestry with Hibernate vs JSF with Hibernate (Object binding question)

Hello there! As I said on previous emails, I'm migrating a JSF app to
tapestry, I'm about to finish. One thing that is really tricking me is
the way that the Hibernate entities are bound on both frameworks (I
might being doing something wrong here).

My edit page has an object (Event) that has a many-to-one relationship
to User, so on the same screen I add/edit an user and an event.

Well on the JSF, when I hit the service  layer (both apps share the
same model desing, with same entities and spring transaction managed
classes) the Event has an user (that is a EnhancedByCGLIB user) with
all it's original values (even those that are not displayed to the
user on the screen), so calling: eventDAO.update(event), updates my
user as well.

On Tapestry side, hitting the service layer, the Event has a User
(POJO) and all other values have just gone, it seems that tapestry,
when binding it's values it does something like this:

User user = new User();
... //set properties present on the screen, dump all other from database
event.setUser(user);

This not only mess my database, but also makes hibernate to create a
new user for my event, instead of updating an existing one.

Well, I'm pretty sure I'm doing stupid things here, could anyone help me out?

Best Regards

Vinicius

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry with Hibernate vs JSF with Hibernate (Object binding question)

Posted by Henri Dupre <he...@gmail.com>.
I don't fully understand your problem... Tapestry doesn't create objects for
you by default (except ASOs)... Page properties are only holders of values.
I'm not sure where you get a second copy of one of your hibernate objects.

Also you should not override equals and hashcode! This might just hide some
underlying session issues... Hibernate doesn't like having several instances
of the same object. Your issue could be related to these methods... At least
without them you'll see if there is not a hibernate session issue there. Do
you reconnect the hibernate objects before the page rewinds?


On 8/21/06, Vinicius Carvalho <ja...@gmail.com> wrote:
>
> Sorry for the delay. Well, object equals and hashcodes are fully
> implemented. What solved the problem was setting the property
> persistent, which I really did no liked :(
>
> When using a volatile property, tapestry is overwriting the objects,
> by fresh new ones, filled only with forms values (as I said, there are
> some properties that are not displayed for the user but important).
>
> When switch to a persistent object (session bound) it preserves the
> values, changing only the ones that changed
>
> This is kinda awkward, I solved using a persistent strategy due the
> lack of time of the project, but I really would like to check it
> deeper, as I'd not like to have a lot of objects floating around my
> session.
>
> Best regards
>
> On 8/19/06, Ryan Holmes <ry...@hyperstep.com> wrote:
> > Just to clarify, Tapestry does not overwrite bound objects with new
> > instances. iow, if a bound value is a Hibernate proxy, that's what
> > you'll get -- for better or worse ;)
> >
> > -Ryan
> >
> > On Aug 19, 2006, at 7:20 AM, Vinicius Carvalho wrote:
> >
> > > Hello there! As I said on previous emails, I'm migrating a JSF app to
> > > tapestry, I'm about to finish. One thing that is really tricking me is
> > > the way that the Hibernate entities are bound on both frameworks (I
> > > might being doing something wrong here).
> > >
> > > My edit page has an object (Event) that has a many-to-one relationship
> > > to User, so on the same screen I add/edit an user and an event.
> > >
> > > Well on the JSF, when I hit the service  layer (both apps share the
> > > same model desing, with same entities and spring transaction managed
> > > classes) the Event has an user (that is a EnhancedByCGLIB user) with
> > > all it's original values (even those that are not displayed to the
> > > user on the screen), so calling: eventDAO.update(event), updates my
> > > user as well.
> > >
> > > On Tapestry side, hitting the service layer, the Event has a User
> > > (POJO) and all other values have just gone, it seems that tapestry,
> > > when binding it's values it does something like this:
> > >
> > > User user = new User();
> > > ... //set properties present on the screen, dump all other from
> > > database
> > > event.setUser(user);
> > >
> > > This not only mess my database, but also makes hibernate to create a
> > > new user for my event, instead of updating an existing one.
> > >
> > > Well, I'm pretty sure I'm doing stupid things here, could anyone
> > > help me out?
> > >
> > > Best Regards
> > >
> > > Vinicius
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> >
> > Ryan Holmes, CISSP
> >
> > ryan@hyperstep.com
> > ph. (213) 626-0026
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Henri Dupre
Actualis Center

Re: Tapestry with Hibernate vs JSF with Hibernate (Object binding question)

Posted by "hv @ Fashion Content" <in...@fashioncontent.com>.
I find that when things seem awkward in Tapestry it is often because I use 
the wrong approach.

If you find yourself forced to create a session when there is no need for 
it, you probably need
to rethink how you use listeners/triggers on page/component.

"Vinicius Carvalho" <ja...@gmail.com> skrev i en meddelelse 
news:fde284ef0608210500p791b56beme335177026ec0539@mail.gmail.com...
> Sorry for the delay. Well, object equals and hashcodes are fully
> implemented. What solved the problem was setting the property
> persistent, which I really did no liked :(
>
> When using a volatile property, tapestry is overwriting the objects,
> by fresh new ones, filled only with forms values (as I said, there are
> some properties that are not displayed for the user but important).
>
> When switch to a persistent object (session bound) it preserves the
> values, changing only the ones that changed
>
> This is kinda awkward, I solved using a persistent strategy due the
> lack of time of the project, but I really would like to check it
> deeper, as I'd not like to have a lot of objects floating around my
> session.
>
> Best regards
>
> On 8/19/06, Ryan Holmes <ry...@hyperstep.com> wrote:
>> Just to clarify, Tapestry does not overwrite bound objects with new
>> instances. iow, if a bound value is a Hibernate proxy, that's what
>> you'll get -- for better or worse ;)
>>
>> -Ryan
>>
>> On Aug 19, 2006, at 7:20 AM, Vinicius Carvalho wrote:
>>
>> > Hello there! As I said on previous emails, I'm migrating a JSF app to
>> > tapestry, I'm about to finish. One thing that is really tricking me is
>> > the way that the Hibernate entities are bound on both frameworks (I
>> > might being doing something wrong here).
>> >
>> > My edit page has an object (Event) that has a many-to-one relationship
>> > to User, so on the same screen I add/edit an user and an event.
>> >
>> > Well on the JSF, when I hit the service  layer (both apps share the
>> > same model desing, with same entities and spring transaction managed
>> > classes) the Event has an user (that is a EnhancedByCGLIB user) with
>> > all it's original values (even those that are not displayed to the
>> > user on the screen), so calling: eventDAO.update(event), updates my
>> > user as well.
>> >
>> > On Tapestry side, hitting the service layer, the Event has a User
>> > (POJO) and all other values have just gone, it seems that tapestry,
>> > when binding it's values it does something like this:
>> >
>> > User user = new User();
>> > ... //set properties present on the screen, dump all other from
>> > database
>> > event.setUser(user);
>> >
>> > This not only mess my database, but also makes hibernate to create a
>> > new user for my event, instead of updating an existing one.
>> >
>> > Well, I'm pretty sure I'm doing stupid things here, could anyone
>> > help me out?
>> >
>> > Best Regards
>> >
>> > Vinicius
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>>
>> Ryan Holmes, CISSP
>>
>> ryan@hyperstep.com
>> ph. (213) 626-0026
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry with Hibernate vs JSF with Hibernate (Object binding question)

Posted by Vinicius Carvalho <ja...@gmail.com>.
Sorry for the delay. Well, object equals and hashcodes are fully
implemented. What solved the problem was setting the property
persistent, which I really did no liked :(

When using a volatile property, tapestry is overwriting the objects,
by fresh new ones, filled only with forms values (as I said, there are
some properties that are not displayed for the user but important).

When switch to a persistent object (session bound) it preserves the
values, changing only the ones that changed

This is kinda awkward, I solved using a persistent strategy due the
lack of time of the project, but I really would like to check it
deeper, as I'd not like to have a lot of objects floating around my
session.

Best regards

On 8/19/06, Ryan Holmes <ry...@hyperstep.com> wrote:
> Just to clarify, Tapestry does not overwrite bound objects with new
> instances. iow, if a bound value is a Hibernate proxy, that's what
> you'll get -- for better or worse ;)
>
> -Ryan
>
> On Aug 19, 2006, at 7:20 AM, Vinicius Carvalho wrote:
>
> > Hello there! As I said on previous emails, I'm migrating a JSF app to
> > tapestry, I'm about to finish. One thing that is really tricking me is
> > the way that the Hibernate entities are bound on both frameworks (I
> > might being doing something wrong here).
> >
> > My edit page has an object (Event) that has a many-to-one relationship
> > to User, so on the same screen I add/edit an user and an event.
> >
> > Well on the JSF, when I hit the service  layer (both apps share the
> > same model desing, with same entities and spring transaction managed
> > classes) the Event has an user (that is a EnhancedByCGLIB user) with
> > all it's original values (even those that are not displayed to the
> > user on the screen), so calling: eventDAO.update(event), updates my
> > user as well.
> >
> > On Tapestry side, hitting the service layer, the Event has a User
> > (POJO) and all other values have just gone, it seems that tapestry,
> > when binding it's values it does something like this:
> >
> > User user = new User();
> > ... //set properties present on the screen, dump all other from
> > database
> > event.setUser(user);
> >
> > This not only mess my database, but also makes hibernate to create a
> > new user for my event, instead of updating an existing one.
> >
> > Well, I'm pretty sure I'm doing stupid things here, could anyone
> > help me out?
> >
> > Best Regards
> >
> > Vinicius
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
> Ryan Holmes, CISSP
>
> ryan@hyperstep.com
> ph. (213) 626-0026
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry with Hibernate vs JSF with Hibernate (Object binding question)

Posted by Ryan Holmes <ry...@hyperstep.com>.
Just to clarify, Tapestry does not overwrite bound objects with new  
instances. iow, if a bound value is a Hibernate proxy, that's what  
you'll get -- for better or worse ;)

-Ryan

On Aug 19, 2006, at 7:20 AM, Vinicius Carvalho wrote:

> Hello there! As I said on previous emails, I'm migrating a JSF app to
> tapestry, I'm about to finish. One thing that is really tricking me is
> the way that the Hibernate entities are bound on both frameworks (I
> might being doing something wrong here).
>
> My edit page has an object (Event) that has a many-to-one relationship
> to User, so on the same screen I add/edit an user and an event.
>
> Well on the JSF, when I hit the service  layer (both apps share the
> same model desing, with same entities and spring transaction managed
> classes) the Event has an user (that is a EnhancedByCGLIB user) with
> all it's original values (even those that are not displayed to the
> user on the screen), so calling: eventDAO.update(event), updates my
> user as well.
>
> On Tapestry side, hitting the service layer, the Event has a User
> (POJO) and all other values have just gone, it seems that tapestry,
> when binding it's values it does something like this:
>
> User user = new User();
> ... //set properties present on the screen, dump all other from  
> database
> event.setUser(user);
>
> This not only mess my database, but also makes hibernate to create a
> new user for my event, instead of updating an existing one.
>
> Well, I'm pretty sure I'm doing stupid things here, could anyone  
> help me out?
>
> Best Regards
>
> Vinicius
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

Ryan Holmes, CISSP

ryan@hyperstep.com
ph. (213) 626-0026



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org