> 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? Thank you very much for your answers... > > 2009/8/17 Gonzalo Aguilar Delgado <[email protected]>: > > 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: [email protected] > For additional commands, e-mail: [email protected]
