Happy to help, please see further answers below.

2009/8/17 Gonzalo Aguilar Delgado <g...@aguilardelgado.com>:
>
>
>> I have several suggestions.
>>
>> The order of the web filters are important. You could also try with
>> with the wicket spring managed apps, im not sure how that applies.
>
> Will check. I didn't know about filter order... Will also check it.
> Thanks!
>
>
>>
>> And are you sure that your filter ( /hibernate/*), get's hit? What's
>> your wicket filter url, the same or?
>
>
> No, It's different. Can I set it to just "/*"? Should I do it that way?
Well it depends, if the hibernate filter should be activated at the
same url's as wicket.

I've never had a case where my wicket filter and osiw did not match.
You might have performance increases if they differ, for example if
you know that you willl never use hibernate on /myapp/ but always put
in /myapp/pages/dynamic/*  for pages that use db lookup..
>
> Thank you very much for your answers...
>
>
>
>>
>> 2009/8/17 Gonzalo Aguilar Delgado <g...@aguilardelgado.com>:
>> > Ok. Maybe I don't understand...
>> >
>> > Let me show the situation. I have Spring + portlet + hibernate config
>> > with transactions working with the current configuration:
>> >
>> > I have my DAO objects under package
>> > com.level2crm.hibernate.enterprise.dao.contact
>> > And model under com.level2crm.model
>> >
>> > I configured one advice:
>> >        <tx:advice id="txAdvice" transaction-manager="txManager">
>> >                <!-- the transactional semantics... -->
>> >                <tx:attributes>
>> >                        <!-- all methods starting with 'get' are read-only 
>> > -->
>> >                        <tx:method name="get*"  propagation="REQUIRED" 
>> > read-only="true" />
>> >                        <!-- other methods use the default transaction 
>> > settings (see below)
>> > -->
>> >                        <tx:method name="*"  propagation="REQUIRED" /> <!--
>> > propagation="SUPPORTS" -->
>> >                </tx:attributes>
>> >        </tx:advice>
>> >
>> > And several pointcuts:
>> >        <aop:config>
>> >                <aop:pointcut id="allModelOperation" expression="execution(*
>> > com.level2crm.model..*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice"
>> > pointcut-ref="allModelOperation"/>
>> >        </aop:config>
>> >
>> >        <aop:config>
>> >                <aop:pointcut id="allDAO" expression="execution(*
>> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
>> >        </aop:config>
>> >
>> >        <aop:config>
>> >                <aop:pointcut id="TRG" expression="execution(*
>> > com.trg.dao.hibernate.*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
>> >        </aop:config>
>> >
>> > <!-- This one does not work -->
>> >    <aop:config>
>> >                <aop:pointcut id="portlets" expression="execution(*
>> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
>> >        </aop:config>
>> >
>> > I tried to configure the open session in view (web.xml):
>> >        <listener>
>> >
>> > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>> >        </listener>
>> >
>> >        <!-- Enable the filters for Hibernate -->
>> >
>> >        <filter>
>> >                <filter-name>opensessioninview</filter-name>
>> >
>> > <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
>> >        </filter>
>> >        <filter-mapping>
>> >                <filter-name>opensessioninview</filter-name>
>> >                <url-pattern>/hibernate/*</url-pattern>
>> >        </filter-mapping>
>> >        <!-- END hibernate filters -->
>> >
>> >
>> >
>> > But I found that this does not work. Because:
>> >
>> >
>> > public class ViewModePage extends org.apache.wicket.markup.html.WebPage
>> > {
>> > ...
>> >
>> >       �...@springbean(name = "userDAOBean")
>> >        private UserDAO userDAO;
>> >
>> >
>> >        IModel loadableUserModel = new LoadableDetachableModel() {
>> >
>> >               �...@override
>> >                protected Object load(){
>> >                        User selectedUser = null;
>> >                        String value =
>> > ((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
>> >                        if(value!=null)
>> >                        {
>> >                                UuidUserType uuid = 
>> > UuidUserType.fromString(value); //Works!!
>> >                                userDAO.testSessoion(uuid);//Works!!
>> >
>> >                                selectedUser = userDAO.find(uuid);//Works!!
>> >
>> >                                if(!userDAO.isAttached(selectedUser)) 
>> > //Works!! But is not
>> > attached!!!
>> >                                {
>> >
>> >                                        userDAO.save(selectedUser); 
>> > //Attach it     //Works!! It
>> > saves/updates the object but it's still not attached
>> >                                }
>> >
>> >
>> >
>> >                                Set<ContactBasicDetail> setDetails =
>> > selectedUser.getContactBasicDetails(); //Works!! It gets the set
>> >                                setDetails.isEmpty(); // FAIL FAIL Cannot 
>> > load lazy
>> >
>> >                                return setDetails.toArray();
>> >                        }
>> >                        return null;
>> >                }
>> >
>> >
>> >        };
>> > ...
>> > }
>> >
>> >
>> > This load() function does not work! It makes the exception. But:
>> >
>> >
>> >        1.- It can get the User. Because the pointcut works inside the
>> >        DAO?
>> >        2.- It can save the object. Because the pointcut works inside
>> >        the DAO?
>> >        3.- It can get the Set. Because the pointcut works inside the
>> >        DAO?
>> >
>> >
>> > The  userDAO.testSessoion(uuid); function inside the DAO object works.
>> > What I do is to get the Hibernate session, check that is ok. And check
>> > also if the transaction was created and I can attach and use object.
>> > Inside the userDAO.testSessoion function I do the same code that in the
>> > load() function but this time everything works!
>> >
>> > I'm sure that it works because it has a session and a open transaction
>> > due to the pointcut defined as follows works above:
>> >
>> >  <aop:config>
>> >  <aop:pointcut id="allDAO" expression="execution(*
>> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
>> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
>> >  </aop:config>
>> >
>> >
>> > What is not working is the pointcut that should provide a
>> > transaction/session to the page:
>> > <!-- This one does not work -->
>> >    <aop:config>
>> >  <aop:pointcut id="portlets" expression="execution(*
>> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
>> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
>> >  </aop:config>
>> >
>> > And I think this has something to do with the hibernate+wicket
>> > configuration. As the page is not created by the Spring bean interface
>> > it cannot
>> > make a proxy around it. So it will never get the session/transaction.
>> >
>> >
>> > Opening a session with the view manually will make my pointcuts not
>> > usable so I will loose the control over what classes
>> > will be managed and over transactions. Do will I?
>> >
>> >
>> >
>> >
>> >> >> Yup so you should either use open session in view or more preferred
>> >> >> AFAIK detachable models.
>> >
>> > Yep, I do it but it does not work. Indeed it fails inside the load()
>> > function. That makes me thing something is wrong configured...
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to