[flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

2008-01-15 Thread andrii_olefirenko
hi, 
these problems caused mainly by AMF3 which is quite low level and
sessionless. as i understand AMF3, it uses references for these
objects only that are in the same request, so it assumes that neither
server nor client remembers what objects were already sent. that's the
main problem - just having this session aware protocol implemented
will make all communication lazy by default. (in addition, it would be
nice to be able to control how deeply object graph should be
serialized for each particular request)

regards, 
Andrii Olefirenko
 

--- In flexcoders@yahoogroups.com, Jeff Vroom [EMAIL PROTECTED] wrote:

 We haven't released the source for blazeds yet but it is coming.  It
 does not contain any AS source generation but I think that is easy to
 layer on and there are a bunch of decent implementations out there.
 There is better support for customizing the serialization process in
 blazeds (improved over 2.5.1).  The beta for blazeds has some of this
 but we are adding even more between beta and the release.  
 
  
 
 Implementing lazy loading is a bit of a pain with hibernate if you have
 to do it using remote object.  There are two major issues:
 
  
 
 1)   the class names of the generated wrapper classes used by
 hibernate mess up the mapping of the class names used to find the right
 AS class.  This one is easy to get around with this PropertyProxy
 mechanism.   In fact, LC DS contains the source to a PropertyProxy
 implementation (HibernatePropertyProxy.java) which you can use with
 remote object to strip the generated class name off before
 serialization.  This has the side effect of returning empty versions of
 all non-loaded lazy properties which brings us to problem 2).  Note that
 hibernate has different mechanisms for doing the lazy loading.. it can
 do byte code modification but I haven't used that technique so I'm not
 sure how it works here. 
 
 2)   If you did not fetch a property with lazy=true in hibernate
 before the session is closed, the attempt to access that property during
 serialization fails with the session closed error.  To get around
 this, you can make sure you access all properties you need before the
 serialization.. this is the approach used by LC DS but because it has a
 model of the association properties, you don't have to code it up
 yourself.  It is done by the assembler so it is automatic.Another
 hacky approach is to put a servlet filter in which opens up a hibernate
 session before calling the MessageBrokerServlet, then close the session
 once it returns.  That means you lose control over the hibernate
 sessions in your application and you have a transaction which is open
 for the entire duration of the request which is not very flexible.
 There might also be performance problems if you have a
 session/transaction open while you are doing I/O.  Not sure that will be
 a problem but these are the reasons we went with the prefetch
 mechanism in LC DS's hibernate assembler.
 
  
 
  In terms of the issues with hibernate in 2.5 and earlier versions, one
 of the trickiest things is that you need to make your
 data-management-config.xml match up with the hibernate config.  We're
 hoping to get a chance into a future version which makes this not
 necessary since the configs are pretty similar.  You also need to do the
 AS code which matches the Java code yourself (or use a 3rd party code
 gen tool).  
 
  
 
 Jeff
 
  
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of andrii_olefirenko
 Sent: Friday, January 11, 2008 5:46 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: Flex + Spring + Hibernate - Lazy=true
 
  
 
 Assemblers are more for CRUD apps. And even with Hibernate assembler, 
 i haven't achieved lazy loading (it was old version of FDS and maybe 
 i didn't try hard but anyway). 
 If anyone has been able to implement lazy loading with LCDS 2.5, let 
 me know so at least i will be assured that this is possible :)
 in addition to lazy loading, there are also problems of multiple 
 instances if the same object, and the need to manually write 
 actionscript counterparts of java objects. IFAIK, there no tool for 
 automated generation AS3 classes out of java classes in BlazeDS. For 
 big projects with permanent changes to the objects it is pain to 
 manually maintain both AS3 and java obejcts sync.
 
 it would be nice to implement all these features in open-sourced 
 BlazeDS, but i didn't find any source code in distribution as for 
 now. 
 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
 , Rodrigo Pereira 
 Fraga rpffoz@ wrote:
 
  Oh my god
  
  =/
  
  But who uses the LCDS, it does not contain a HibernateAssembler 
  which implements the use of lazy?
  
  
  --- In flexcoders@yahoogroups.com
 mailto:flexcoders%40yahoogroups.com , andrii_olefirenko andriyo@ 
  wrote:
  
   BlazeDS (and LCDS as far as i remember) doesn't support this out 
 of 
   box

[flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

2008-01-13 Thread den.orlov
Check Granite Data Services. They handle lazy loading properties
support, they have as3 code generator.

Den



[flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

2008-01-11 Thread andrii_olefirenko
BlazeDS (and LCDS as far as i remember) doesn't support this out of 
box. There are workarounds like 1) make you own DTO (hibernate free) 
2) prefetch object dependencies  3) include metadata about lazy 
properties with you objects, control externalization to handle 
objects with metadata and so on. 
if you develop with Hibernate (or EJB3), lack of lazy object support 
makes BlazeDS simply unusable for real enterprise application devs.

--- In flexcoders@yahoogroups.com, Rodrigo Pereira Fraga 
[EMAIL PROTECTED] wrote:

 Someone has some solution to use the Pattern OpenSessionInView with 
 Flex using BlazeDS? 
 
 I am using Spring and it contains a OpenSessionInViewFilter used in 
 web.xml, and a OpenSessionInViewInterceptor. But it is different 
with 
 Flex +) 
 
 Someone has idea of how I can use the Lazy = true to hibernate with 
the 
 Flex + Spring?
 
 
 
 Atenciosamente:
 ---
 | Rodrigo Pereira Fraga |
  http://www.digows.com 
  
 e-mails: [EMAIL PROTECTED]
  [EMAIL PROTECTED]
 ---





[flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

2008-01-11 Thread Rodrigo Pereira Fraga
Oh my god

=/

But who uses the LCDS, it does not contain a HibernateAssembler 
which implements the use of lazy?


--- In flexcoders@yahoogroups.com, andrii_olefirenko [EMAIL PROTECTED] 
wrote:

 BlazeDS (and LCDS as far as i remember) doesn't support this out of 
 box. There are workarounds like 1) make you own DTO (hibernate 
free) 
 2) prefetch object dependencies  3) include metadata about lazy 
 properties with you objects, control externalization to handle 
 objects with metadata and so on. 
 if you develop with Hibernate (or EJB3), lack of lazy object 
support 
 makes BlazeDS simply unusable for real enterprise application devs.
 
 --- In flexcoders@yahoogroups.com, Rodrigo Pereira Fraga 
 rpffoz@ wrote:
 
  Someone has some solution to use the Pattern OpenSessionInView 
with 
  Flex using BlazeDS? 
  
  I am using Spring and it contains a OpenSessionInViewFilter used 
in 
  web.xml, and a OpenSessionInViewInterceptor. But it is different 
 with 
  Flex +) 
  
  Someone has idea of how I can use the Lazy = true to hibernate 
with 
 the 
  Flex + Spring?
  
  
  
  Atenciosamente:
  ---
  | Rodrigo Pereira Fraga |
   http://www.digows.com 
   
  e-mails: rpffoz@
   rfraga@
  ---
 





[flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

2008-01-11 Thread andrii_olefirenko
Assemblers are more for CRUD apps. And even with Hibernate assembler, 
i haven't achieved lazy loading (it was old version of FDS and maybe 
i didn't try hard but anyway). 
If anyone has been able to implement lazy loading with LCDS 2.5, let 
me know so at least i will be assured that this is possible :)
in addition to lazy loading, there are also problems of multiple 
instances if the same object, and the need to manually write 
actionscript counterparts of java objects. IFAIK, there no tool for 
automated generation AS3 classes out of java classes in BlazeDS. For 
big projects with permanent changes to the objects it is pain to 
manually maintain both AS3 and java obejcts sync.

it would be nice to implement all these features in open-sourced 
BlazeDS, but i didn't find any source code in distribution as for 
now. 
--- In flexcoders@yahoogroups.com, Rodrigo Pereira 
Fraga [EMAIL PROTECTED] wrote:

 Oh my god
 
 =/
 
 But who uses the LCDS, it does not contain a HibernateAssembler 
 which implements the use of lazy?
 
 
 --- In flexcoders@yahoogroups.com, andrii_olefirenko andriyo@ 
 wrote:
 
  BlazeDS (and LCDS as far as i remember) doesn't support this out 
of 
  box. There are workarounds like 1) make you own DTO (hibernate 
 free) 
  2) prefetch object dependencies  3) include metadata about lazy 
  properties with you objects, control externalization to handle 
  objects with metadata and so on. 
  if you develop with Hibernate (or EJB3), lack of lazy object 
 support 
  makes BlazeDS simply unusable for real enterprise application 
devs.
  
  --- In flexcoders@yahoogroups.com, Rodrigo Pereira Fraga 
  rpffoz@ wrote:
  
   Someone has some solution to use the Pattern OpenSessionInView 
 with 
   Flex using BlazeDS? 
   
   I am using Spring and it contains a OpenSessionInViewFilter 
used 
 in 
   web.xml, and a OpenSessionInViewInterceptor. But it is 
different 
  with 
   Flex +) 
   
   Someone has idea of how I can use the Lazy = true to hibernate 
 with 
  the 
   Flex + Spring?
   
   
   
   Atenciosamente:
   ---
   | Rodrigo Pereira Fraga |
http://www.digows.com 

   e-mails: rpffoz@
rfraga@
   ---
  
 





RE: [flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

2008-01-11 Thread Jeff Vroom
We haven't released the source for blazeds yet but it is coming.  It
does not contain any AS source generation but I think that is easy to
layer on and there are a bunch of decent implementations out there.
There is better support for customizing the serialization process in
blazeds (improved over 2.5.1).  The beta for blazeds has some of this
but we are adding even more between beta and the release.  

 

Implementing lazy loading is a bit of a pain with hibernate if you have
to do it using remote object.  There are two major issues:

 

1)   the class names of the generated wrapper classes used by
hibernate mess up the mapping of the class names used to find the right
AS class.  This one is easy to get around with this PropertyProxy
mechanism.   In fact, LC DS contains the source to a PropertyProxy
implementation (HibernatePropertyProxy.java) which you can use with
remote object to strip the generated class name off before
serialization.  This has the side effect of returning empty versions of
all non-loaded lazy properties which brings us to problem 2).  Note that
hibernate has different mechanisms for doing the lazy loading.. it can
do byte code modification but I haven't used that technique so I'm not
sure how it works here. 

2)   If you did not fetch a property with lazy=true in hibernate
before the session is closed, the attempt to access that property during
serialization fails with the session closed error.  To get around
this, you can make sure you access all properties you need before the
serialization.. this is the approach used by LC DS but because it has a
model of the association properties, you don't have to code it up
yourself.  It is done by the assembler so it is automatic.Another
hacky approach is to put a servlet filter in which opens up a hibernate
session before calling the MessageBrokerServlet, then close the session
once it returns.  That means you lose control over the hibernate
sessions in your application and you have a transaction which is open
for the entire duration of the request which is not very flexible.
There might also be performance problems if you have a
session/transaction open while you are doing I/O.  Not sure that will be
a problem but these are the reasons we went with the prefetch
mechanism in LC DS's hibernate assembler.

 

 In terms of the issues with hibernate in 2.5 and earlier versions, one
of the trickiest things is that you need to make your
data-management-config.xml match up with the hibernate config.  We're
hoping to get a chance into a future version which makes this not
necessary since the configs are pretty similar.  You also need to do the
AS code which matches the Java code yourself (or use a 3rd party code
gen tool).  

 

Jeff

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of andrii_olefirenko
Sent: Friday, January 11, 2008 5:46 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Flex + Spring + Hibernate - Lazy=true

 

Assemblers are more for CRUD apps. And even with Hibernate assembler, 
i haven't achieved lazy loading (it was old version of FDS and maybe 
i didn't try hard but anyway). 
If anyone has been able to implement lazy loading with LCDS 2.5, let 
me know so at least i will be assured that this is possible :)
in addition to lazy loading, there are also problems of multiple 
instances if the same object, and the need to manually write 
actionscript counterparts of java objects. IFAIK, there no tool for 
automated generation AS3 classes out of java classes in BlazeDS. For 
big projects with permanent changes to the objects it is pain to 
manually maintain both AS3 and java obejcts sync.

it would be nice to implement all these features in open-sourced 
BlazeDS, but i didn't find any source code in distribution as for 
now. 
--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Rodrigo Pereira 
Fraga [EMAIL PROTECTED] wrote:

 Oh my god
 
 =/
 
 But who uses the LCDS, it does not contain a HibernateAssembler 
 which implements the use of lazy?
 
 
 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com , andrii_olefirenko andriyo@ 
 wrote:
 
  BlazeDS (and LCDS as far as i remember) doesn't support this out 
of 
  box. There are workarounds like 1) make you own DTO (hibernate 
 free) 
  2) prefetch object dependencies 3) include metadata about lazy 
  properties with you objects, control externalization to handle 
  objects with metadata and so on. 
  if you develop with Hibernate (or EJB3), lack of lazy object 
 support 
  makes BlazeDS simply unusable for real enterprise application 
devs.
  
  --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com , Rodrigo Pereira Fraga 
  rpffoz@ wrote:
  
   Someone has some solution to use the Pattern OpenSessionInView 
 with 
   Flex using BlazeDS? 
   
   I am using Spring and it contains a OpenSessionInViewFilter 
used 
 in 
   web.xml