Hej Martin

The thing is, that this object does not even exist. At least not if I 
understand the meaning of a "request" the right way.

What I do is:
# A DAO extending HibernateDaoSupport finds all records or a record with a 
specifc id (ScanJourLinkHbmDAO)
# The Page-objects get records or a record by means of a (shared) 
manager-class, which has a pointer to the DAO
# Then in danafileResultPage.jsf I have a table, which shows all records based 
on DanafileResultPage.java getting the records from the database via manager 
and DAO
# Each row in the table contains links to edit a record in a new page 
(danafileScanJourModifyPage.jsf). The Page object for the new page 
(DanafileScanJourModifyPage.java) has a property (idLink) which I access via 
a MyFaces <t:updateActionListener> tag. Then in setIdLink(String anId) I try 
to get the record from the database by means of the manager, which then calls 
the DAO ...
=> I have no pointer to the object in either the Page, manager or DAO class. 
So I cannot call session.update(object) :-( And I guess that the call to a 
new page is a new request.

Am I doing something wrong?

Regards ... Rick

<t:dataTable
        id="scanJourLinksTable"
        styleClass="standardTable"
        columnClasses="list-column-left"
        headerClass="list-header-left"
        rowClasses="list-row-even, list-row-odd"
        value="#{DanafileResultPage.scanJourLinks}"
        var="links"
>   
        <h:column>
                <f:facet name="header">
                        <h:outputText value=""/>
                </f:facet>
                <h:commandLink action="edit_link" immediate="true">
                        <h:outputText value="#{msg.edit}" /> 
                        <t:updateActionListener 
property="#{DanafileScanJourModifyPage.idLink}" 
value="#{links.id}" />
                </h:commandLink>
        </h:column>

public class DanafileScanJourModifyPage extends Page {
        public void setIdLink(String anId) {
                if (logger.isDebugEnabled()) {
                        logger.debug("getting link with id= " + anId);
                }
                link = danafileManager.findScanJourLink(Long.valueOf(anId));
                setUpdating(true);
        } //public void setId(String)

public class DanafileManager {  
        public ScanJourLink findScanJourLink(Long id) {
                return scanJourLinkDAO.findScanJourLink(id);
        } //END public ScanJourLink findScanJourLink(Long)

public class ScanJourLinkHbmDAO extends HibernateDaoSupport implements 
IScanJourLinkDAO {
        //implements IScanJourLinkDAO
        public ScanJourLink findScanJourLink(Long id) {
                ScanJourLink link = (ScanJourLink) 
getHibernateTemplate().load(ScanJourLink.class, id);
                if (null == link) {
                        throw new 
ObjectRetrievalFailureException(ScanJourLink.class, id);
                }
                return link;
        }


Onsdag 31 august 2005 12:26 skrev Martin Marinschek:

> A very short hint from my side:
>
> that exception means this object is not in the session anymore. You
> can easily reapply it to the session by calling
>
> session.update(object)
>
> If you are sure that your object has not changed since it was last in
> the session, you can call:
>
> session.lock(object, LockMode.NONE);
>
> regards,
>
> Martin
>
> On 8/31/05, Werner Punz <[EMAIL PROTECTED]> wrote:
> > I think before giving a short answer... I will give you a detailed
> > explanation via a links:
> >
> > http://wiki.apache.org/myfaces/HibernateAndMyFaces?highlight=%28hibernate
> >%29
> >
> > This small article describes exactly the problems you run into and how
> > to solve them...
> >
> > Werner
> >
> > Rick Gruber-Riemer wrote:
> > > Hej
> > >
> > > I use MyFaces (1.0.9), Hibernate (3.0.5) and Spring (1.22) in my
> > > webapplication. When I get a list of records from the database in a
> > > table or make a new record using a form everything works fine. However
> > > when I try to edit a record in a form, I get a
> > > org.hibernate.LazyInitializationException error on opening the
> > > editform. I understand this has something to do with the Hibernate
> > > sessions. And it has nothing to do with MyFaces in particular. And I
> > > have found some hints by googeling like Spring's
> > > OpenSessionInViewFilter. However I do not have a clue what to change
> > > where in the configuration.
> > >
> > > => Has somebody used JSF+Spring+Hibernate successfully?
> > > => Downloadable sample code?
> > > => Do I need the jsf-spring integration library?
> > >
> > > Any hint would be much appreciated ... Rick
> > >
> > > <hibernate-mapping>
> > >       <class
> > > name="dk.trafikstyrelsen.data.transfer.dto.railsecurity.danafile.ScanJo
> > >urLink" table="DANAFILE.SCANJOUR_LINK">
> > >               <id name="id" type="long" column="ROW_ID">
> > >                       <meta attribute="scope-set">protected</meta>
> > >                       <generator class="sequence">
> > >                 <param name="sequence">DANAFILE.SEQNUMBER</param>
> > >               </generator>
> > >         </id>
> > >               <version column="REVISION" name="revision" />
> > >               <property name="objId" type="string" not-null="true"/>
> > >               <property name="scanJourNumber" type="int"
> > > column="SCANJOUR_NUMBER" not-null="true"/> <property name="notes"
> > > type="string" column="NOTES" not-null="false"/> <property name="active"
> > > type="yes_no" column="ACTIVE" not-null="true" /> <property
> > > name="createdBy" type="string" column="CREATED_BY" not-null="true"/>
> > > <property name="lastUpdatedBy" type="string" column="LAST_UPD_BY"
> > > not-null="true"/> <property name="createdDate" type="timestamp"
> > > column="CREATED_DT" not-null="true"/> <property name="lastUpdatedDate"
> > > type="timestamp" column="LAST_UPD_DT" not-null="true"/> </class>
> > > </hibernate-mapping>
> > >
> > > <beans>
> > >       <bean id="danafileHbmDS"
> > > class="oracle.jdbc.pool.OracleDataSource"> <property
> > > name="driverType"><value>oracle.jdbc.OracleDriver</value></property>
> > > <property
> > > name="URL"><value>jdbc:oracle:thin:@10.0.0.3:1521:dhdvl</value></proper
> > >ty> <property name="user"><value>danafile_web</value></property>
> > > <property name="password"><value>styr3ls3n</value></property> </bean>
> > >
> > >       <!-- Hibernate SessionFactories -->
> > >       <bean id="danafileHbmSF"
> > > class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> > > <property name="dataSource"><ref local="danafileHbmDS"/></property>
> > > <property name="mappingResources">
> > >                       <list>
> > >                              
> > > <value>dk/trafikstyrelsen/data/transfer/dto/railsecurity/danafile/ScanJ
> > >ourLink.hbm.xml</value> </list>
> > >               </property>
> > >               <property name="hibernateProperties">
> > >                       <props>
> > >                               <prop
> > > key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
> > > <prop key="hibernate.query.substitutions">yes 'Y', no 'N'</prop> <prop
> > > key="hibernate.show_sql">true</prop> </props>
> > >               </property>
> > >       </bean>
> > >
> > >       <!-- Transaction manager for a single Hibernate SessionFactory
> > > (alternative to JTA) --> <bean id="transactionManager"
> > > class="org.springframework.orm.hibernate3.HibernateTransactionManager">
> > > <property name="sessionFactory"><ref local="danafileHbmSF"/></property>
> > > </bean>
> > >
> > >       <bean id="scanJourLinkDAO"
> > > class="dk.trafikstyrelsen.data.transfer.dao.railsecurity.danafile.ScanJ
> > >ourLinkHbmDAO"> <property name="sessionFactory"><ref
> > > local="danafileHbmSF"/></property> </bean>
> > > </beans>
> > >
> > >
> > > ERROR - LazyInitializationException.<init>(19) | could not initialize
> > > proxy - the owning Session was closed
> > > org.hibernate.LazyInitializationException: could not initialize proxy -
> > > the owning Session was closed at
> > > org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInit
> > >ializer.java:53) at
> > > org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractL
> > >azyInitializer.java:84) at
> > > org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer
> > >.java:134) at
> > > dk.trafikstyrelsen.data.transfer.dto.railsecurity.danafile.ScanJourLink
> > >$$EnhancerByCGLIB$$c24a4569.getScanJourNumber(<generated>) at
> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja
> > >va:39) at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
> > >rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585)
> > >         at
> > > org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolver
> > >Impl.java:419) at
> > > org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImp
> > >l.java:104) at
> > > org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParser
> > >Helper.java:555) at
> > > org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145) at
> > > org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:4
> > >41)

Reply via email to