The set/get methods are required for collections, so you are doing
that part right. As far as that addable warning goes, I would say
ignore it. I think that its spitting out even when it shouldn't and
I've been meaning to file a bug report about it. If its working as
expected to worry, if not give a holler.

<!--- end meaningful message here -->  :)

The addable attribute is (or at least should be) taken care of if you
have two methods of type:
removeHighScore(HighScroe score) 
and
addHighScore(HighScore score)
However, I have those methods in my classes but I still get the
warning. Go figure :-/  anyone else here perhaps know why or want to
set me straight on what I'm doing wrong with this. I know we have
discussed it before, but hey, its worth rehashing me thinks.

-Nick


On Mon, 18 Oct 2004 12:16:05 +0800, Sean Liang
<[EMAIL PROTECTED]> wrote:
>  
> Anyone who has the experience in using collection, please kindly take a look
> at my code and show me a way. 
>   
> ------------- part of mapping file ----------- 
> <class identity="id" key-generator="HIGH-LOW" name="model.Tournament"> 
>     <map-to table="tournament" /> 
>         <field name="id" type="integer"> 
>             <sql name="id" type="integer" /> 
>         </field>
>         <field name="highScore" type="model.HighScore"
> collection="collection">
>             <sql many-key="tournament" />
>         </field>
> </class> 
> <class identity="id" key-generator="HIGH-LOW" name="model.HighScore">
>     <map-to table="highscore" /> 
>         <field name="id" type="integer">
>             <sql name="id" type="integer" />
>         </field> 
>         <field name="score" type="double">
>             <sql name="score" type="double" />
>         </field>
>         <field name="tournament" type="model.Tournament">
>             <sql name="tournament" />
>         </field>
> </class>
>  
>   
> ------------- part of Tournament.java ----------- 
>     private Collection highScoreList = new ArrayList(); 
>     public void addHighScore(HighScore highScore) {
>         highScoreList.add(highScore); 
>         highScore.setTournament(this);
>     }
>     public Collection getHighScore() {
>         return highScoreList;
>     }
>  
> It then gives me an exception: 
> org.exolab.castor.jdo.DataObjectAccessException: no method to set value for
> field: model.HighScore in class: ClassMolder model.Tournament
>  at org.exolab.castor.persist.FieldMolder.setValue(FieldMolder.java:347)
>  at
> org.exolab.castor.persist.ClassMolder.revertObject(ClassMolder.java:2562)
>  at org.exolab.castor.persist.LockEngine.revertObject(LockEngine.java:848)
>  at
> org.exolab.castor.persist.TransactionContext.rollback(TransactionContext.java:1760)
>  at
> org.exolab.castor.jdo.engine.DatabaseImpl.rollback(DatabaseImpl.java:569)
>  ...... 
>   
> It seems that the setter is required for the collection type? But I didn't
> find it in the Product.java of JDO example. 
>   
> After adding the setter method: 
>  
> ------------- part of Tournament.java -----------    public void
> setHighScore(Collection list) {
>         highScoreList = list;
>     }
>  
> It tells me a warning this time: 
> org.exolab.castor.persist.CollectionProxy$ColProxy add
> Warning: FieldMolder FieldMolder of
> model.Tournament.sethighScore(model.HighScore highScore) is not addable;
> collection needs to set for object type model.HighScore.
>  
> I was confused, could anybody provide me a good practice of collection
> mapping in JDO? 
>   
>   
> Thanks, 
> Sean 
>   
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
> 
> 
>



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

Reply via email to