Hello,

I use GWT 2.0 as UI layer on my project. On server side, I use
Hibernate. For example, this is 2 domains entities that I have :

    public class User {
          private Collection<Role> roles;
          @ManyToMany(cascade = CascadeType.ALL, fetch =
FetchType.LAZY, mappedBy = "users", targetEntity = Role.class)
        public Collection<Role> getRoles() {
                return roles;
        }
          ...
    }

    public class Role {
          private Collection<User> users;
          @ManyToMany(cascade = CascadeType.ALL, fetch =
FetchType.LAZY, targetEntity = User.class)
        public Collection<User> getUsers() {
                return users;
        }
          ...
    }

On my DAO layer, I use **UserDAO** that extends
**HibernateDAOSupport** from Spring. UserDAO has **getAll** method to
return all of Users.

And on my DAO service, I use **UserService** that uses userDAO to
getAll of Users.

So, when I get all of Users from UsersService, Users entities returned
are detached from Hibernate session. For that reason, I don't want to
use **getRoles()** method on Users instance that I get from my
service.

What I want is just to transfer my list of Users thanks to a RPC
Service to be able to use others informations of Users in client side
with GWT.

Thus, my main problem is to be able to convert PersistentBag in
Users.roles in simple List to be able to transfer via RPC the Users.
To do that, I have seen that Gilead Framework could be a solution.

In order to use Gilead, I have changed my domains entities. Now, they
extend **net.sf.gilead.pojo.gwt.LightEntity** and they respect
JavaBean specification.

On server, I expose my services via RPC thanks to GwtRpcSpring
framework (http://code.google.com/p/gwtrpc-spring/). This framework
has an advice that makes easier Gilead integration.

My applicationContext contains the following configuration for
Gilead :

        <bean id="gileadAdapterAdvisor"
class="org.gwtrpcspring.gilead.GileadAdapterAdvice" />
        <aop:config>
                <aop:aspect id="gileadAdapterAspect" ref="gileadAdapterAdvisor">
                        <aop:pointcut id="gileadPointcut"
                                expression="execution(public *
com.google.gwt.user.client.rpc.RemoteService.*(..))" />
                        <aop:around method="doBasicProfiling" pointcut-
ref="gileadPointcut" />
                </aop:aspect>
        </aop:config>

        <bean id="proxySerializer"
class="net.sf.gilead.core.serialization.GwtProxySerialization" />

        <bean id="proxyStore"
class="net.sf.gilead.core.store.stateless.StatelessProxyStore">
                <property name="proxySerializer" ref="proxySerializer" />
        </bean>

        <bean id="persistenceUtil"
class="net.sf.gilead.core.hibernate.HibernateUtil">
                <property name="sessionFactory" ref="sessionFactory" />
        </bean>

        <bean class="net.sf.gilead.core.PersistentBeanManager">
                <property name="proxyStore" ref="proxyStore" />
                <property name="persistenceUtil" ref="persistenceUtil" />
        </bean>


The code of the the method doBasicProfiling is the following :

        @Around("within(com.google.gwt.user.client.rpc.RemoteService..*)")
        public Object doBasicProfiling(ProceedingJoinPoint pjp) throws
Throwable {
                if (log.isDebugEnabled()) {
                        String className = 
pjp.getSignature().getDeclaringTypeName();
                        String methodName = className
                                        .substring(className.lastIndexOf(".") + 
1)
                                        + "." + pjp.getSignature().getName();
                        log.debug("Wrapping call to " + methodName
                                        + " for PersistentBeanManager");
                }
                GileadHelper.parseInputParameters(pjp.getArgs(), beanManager,
                                RemoteServiceUtil.getThreadLocalSession());
                Object retVal = pjp.proceed();
                retVal = GileadHelper.parseReturnValue(retVal, beanManager);

                return retVal;
        }

With that configuration, when I run my application and I use my RPC
Service that gets all of Users, I obtain a lazy initialization
exception from Hibernate from Users.roles.

I am disappointed because I thought that Gilead would let me to
serialize my domain entities even if these entities contained
PersistentBag.

It's not one of the goals of Gilead ?

So, someone would know how to configure Gilead (with GwtRpcSpring or
other solution) to be able to transfer domain entities without Lazy
exception ?

Thanks by advance for your help.

Sylvain

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to