Expand my Community achievements bar.

How to expose Hibernate 'non' conventional beans into flex apps via remoting

Avatar

Level 1
I am relatively new to the flex world. I am from the
Spring/Hibernate world.

In Hibernate, the POJO object or domain object , or simply
beans that you use to persist you object into the database does not
have to follow the bean definition/contract, i.e: public default
constructor with getter/setters. There are good reasons behind
creating those kind of 'hibernate beans' (I will call them that way
for lack of a better name). In fact, only defining a one-parameter
constructor (i.e. omitting the default one) guaranties you that
your client cannot invoke your API without that needed parameter.
Likewise, exposing only the getters for some private member
variables (without the setters) make sense when you don't want that
variable to ever change, etc....hibernate can do all that using
cglib, etc....



Now, my understanding of Flex and how remote services work
(from what I could see in all the samples around about
hibernate/spring), is that your java server bean get proxied
'dynamically' or 'statically' if I wish into an Actionscript class
object according to the rule: "values found in public bean
properties with get/set methods and public variables ", therefore
my public getVariable() from my 'hibernate' bean does not get sent
back.

This is creating me tons of problems, because the server API
already exist and we already have a JSF implementation using
it....Changing into flex is just my own initiative to prove that we
can get better UI...



What is flex/BlazeDS solution for fixing this case?

One solution that comes to mind (not very bright, but should
work) is to build a plain java bean object for each of these
'hibernate' beans to ensure the translation on both side between
the 'hibernate bean' and the 'expected' bean from flex. From the
server to the client, It would to copy the content of the hibernate
bean and return those 'proper' beans back to flex. On the way out
(from the client to the server), it would have to recreate the bean
as exposed on the server before sending it to the server).... It's
probably not the best solution, especially considering that
eventually as some point, I will need to define another set of
those object, in flex, using actionscript (I think these are what
you guys call VOs) in order to do strong typing in
flex........becomes very tough to manage!



Any input would be valuable.

Thank you,

0 Replies