OK thanks.

I only have this exception: java.lang.ClassCastException. So I don't have
lazy loading.

Coud you just confirm to me that, to implement lazy loading, for the
"Consultant" class I have to:

A- set "lazy" to "true", like this:
---------------
<class name="Consultant"  identity="consID" key-generator="IDENTITY">
  <map-to table="CONSULT"/>
  ...
  <field name="grades" type="Grade" lazy="true" collection ="collection" >
    <sql many-key="CONSID" />
  </field>
</class>
---------------

B- and write my Consultant class like this:
---------------
public class Consultant {
        ...
        private Collection grades = new ArrayList();
        ...
        public Collection getGrades() {
                return this.grades;
        }       
        public void setGrades(Collection g) {
                this.grades = g;
        }
        public void addGrade(Collection g) {
                this.grades.add(g);
        }
}
---------------



Thanks !

Alexandre


-----Message d'origine-----
De : Denis Sukhoroslov [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 7 mars 2003 10:24
À : [EMAIL PROTECTED]
Objet : Re: [castor-dev] Lazy loading - how to be sure ?


An error skack should look like:

java.lang.RuntimeException: Transaction is closed!
   at org.exolab.castor.persist.RelationCollection$IteratorImp.lazyLoad
  ..........................


----- Original Message -----
From: "Alexandre Hoang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 07, 2003 11:58 AM
Subject: Re: [castor-dev] Lazy loading - how to be sure ?


> Hello,
>
> In order to check if my objects of the class "Consultant" are lazily
loaded,
> I have written this piece of code:
> ------------------
> QueryResults results = query.execute();
> Consultant cons = new Consultant();
> cons = (Consultant)results.next();
>
> Object[] objArray = cons.getGrades().toArray();
>
> Iterator it = cons.getGrades().iterator();
> while(it.hasNext()) {
> Grade g =(Grade)it.next();
> System.out.println(g.toString());
> }
> ------------------
> When I set lazy="false" in the mapping file, this piece of code is OK.
> When I set lazy="true", I have an exception with the line:
> "Object[] objArray = cons.getGrades().toArray();"
> Is it a reasonable piece of evidence that my "Consultant" objects are
lazily
> loaded ?
>
>
> Thanks,
>
> Alexandre
>
>
>
>
> -----Message d'origine-----
> De : Denis Sukhoroslov [mailto:[EMAIL PROTECTED]
> Envoyé : jeudi 6 mars 2003 18:04
> À : [EMAIL PROTECTED]
> Objet : Re: [castor-dev] Lazy loading - how to be sure ?
>
>
> Yes. If this collection is lazily loaded you should get an exception on
> line: Grade g =(Grade)it.next();
>
> ----- Original Message -----
> From: "Alexandre Hoang" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, March 06, 2003 7:09 PM
> Subject: [castor-dev] Lazy loading - how to be sure ?
>
>
> > Hello,
> >
> > Sorry for the dumb question, but I need to know...
> >
> > I have modified my "mapping.xml" file and my classes to enable lazy
> loading.
> > I can save my objects and load them correctly.
> > But is there a (simple) way I can verify that my objects are really
loaded
> > lazily ?
> > --------------
> > In this case, I have :
> >
> > cons = (Consultant)results.next();
> > Collection al = cons.getGrades();
> > Iterator it =al.iterator();
> > while(it.hasNext()) {
> > Grade g =(Grade)it.next();
> > System.out.println(g.getSkill());
> > }
> >
> > --------------
> > Thanks,
> >
> > Alexandre
> >
> >
> >
> >
> >
> > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
> *
> > Confidentiality Notice :
> > The information contained in this e-mail message is intended only for
the
> > personal and confidential use of the recipient(s) named above. If the
> reader
> > of this message is not the intended recipient or an agent responsible
for
> > delivering it to the intended recipient, you are hereby notified that
you
> > have received this document in error and that any review, dissemination,
> > distribution, or copying of this message is strictly prohibited. If you
> have
> > received this communication in error, please notify
[EMAIL PROTECTED]
> > immediately by e-mail, and delete the original message.
> > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
> *
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> >
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
>
>
>
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
> Confidentiality Notice :
> The information contained in this e-mail message is intended only for the
> personal and confidential use of the recipient(s) named above. If the
reader
> of this message is not the intended recipient or an agent responsible for
> delivering it to the intended recipient, you are hereby notified that you
> have received this document in error and that any review, dissemination,
> distribution, or copying of this message is strictly prohibited. If you
have
> received this communication in error, please notify [EMAIL PROTECTED]
> immediately by e-mail, and delete the original message.
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev




* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
Confidentiality Notice : 
The information contained in this e-mail message is intended only for the
personal and confidential use of the recipient(s) named above. If the reader
of this message is not the intended recipient or an agent responsible for
delivering it to the intended recipient, you are hereby notified that you
have received this document in error and that any review, dissemination,
distribution, or copying of this message is strictly prohibited. If you have
received this communication in error, please notify [EMAIL PROTECTED]
immediately by e-mail, and delete the original message.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to