Hi Dougie,

I think it's a good thing to run your PersonMap
implementation in a two tier test case first. This
is easy to debug and the test case is easy to write.

regards,
Armin

----- Original Message -----
From: "���զ�" <[EMAIL PROTECTED]>
To: "Armin Waibel" <[EMAIL PROTECTED]>
Cc: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, April 01, 2003 3:00 AM
Subject: Re: DMapImpl how to implement ManageableCollection ?


> Hi Armin:
>     Because I deploy OJB to JBoss, my application must run on JBoss.
Its
> test case must also deployed to JBoss.
> I can post the two simple class ,Person and Project calss, if these
are
> useless to debug. It doesn't matter. I will give this solution.
>
> <!-------------------------------------------------------------Person
> class----------------------------------------------------->
> package com.dsc.nana.domain.organization;
>
> import java.util.*;
>
> public class Person{
>     private String OID;
>     public String getOID(){
>         this.OID;
>     }
>     public void setOID(String pNewValue){
>         this.OID= pNewValue;
>     }
>     /** name of person*/
>     private String name = null;
>
>     /** name's getter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public String getName() {
>         return this.name;
>     }
>
>     /** name's setter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public void setName(String pNewValue) {
>         this.name = pNewValue;
>     }
>
>     /** OID of the project that person join */
>     private String containerOID = null;
>
>     /** containOID's getter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public String getContainerOID() {
>         return this.containerOID;
>     }
>
>     /** containOID's setter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public void setContainerOID(String pNewValue) {
>         this.containerOID = pNewValue;
>     }
>
>     /** the project that person join  */
>     private Project container = null;
>
>     /** container's getter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public Project getContainer() {
>         return this.container;
>     }
>
>     /** container's setter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public void setContainer(Project pNewValue) {
>         this.container = pNewValue;
>         pNewValue.addPerson(this);
>     }
>
>     public Person() {
>     }
> }
>
<!-----------------------------------------Project----------------------
----
> ------------------------->
> package com.dsc.nana.domain.organization;
>
> import com.dsc.nana.persistence.PersistentObject;
> import java.util.*;
> import org.odmg.DMap;
> import org.apache.ojb.odmg.collections.DMapImpl;
>
> public class Project{
>
>     private String OID;
>     public String getOID(){
>         this.OID;
>     }
>     public void setOID(String pNewValue){
>         this.OID= pNewValue;
>     }
>
>     private String name = null;
>
>     /** name's getter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public String getName() {
>         return this.name;
>     }
>
>     /** name's setter
>      * @author Dogie Tsai
>      * @since 2002/10/22
>      */
>     public void setName(String pNewValue) {
>         this.name = pNewValue;
>     }
>     private DMap persons;
>
>     public DMap getPersons(){
>         if (this.persons == null){
>             this.persons = new PersonMap ();
>         }
>         return this.persons ;
>     }
>     public void setPersons(DMap pNewValue){
>         this.persons = pNewValue;
>     }
>     public void addPerson(Person pMember){
>         if (this.getPersons().containsValue(pMember)){
>
>         } else {
>             this.getPersons().put(pMember.getOID() ,pMember);
>             pMember.setContainer(this);
>         }
>     }
>     public Project() {
>     }
> }
>
> I just new a project and a person.The Person add in the project. Then
store
> project.
> > Hi Dougie,
> >
> > sorry I don't have a clue what's going wrong.
> > Could you post a test case?
> >
> > regards,
> > Armin
> >
> > ----- Original Message -----
> > From: "���զ�" <[EMAIL PROTECTED]>
> > To: "OJB Users List" <[EMAIL PROTECTED]>
> > Sent: Monday, March 31, 2003 5:33 AM
> > Subject: DMapImpl how to implement ManageableCollection ?
> >
> >
> > Hi Armin:
> >     I try to implement ManageableCollection via DMapImpl,but it
can't
> > work.
> > I don't know what's worng with it. I design a PersonMap class that
> > extends DMapImpl and implement ManageableCollection, as like:
> > package com.dsc.nana.domain.organization;
> >
> > import org.apache.ojb.odmg.collections.DMapImpl;
> > import org.apache.ojb.broker.ManageableCollection;
> > import java.util.Iterator;
> > import com.dsc.nana.persistence.PersistentObject;
> >
> > public class PersonMap extends DMapImpl implements
ManageableCollection{
> >
> >     public PersonMap() {
> >         super();
> >     }
> >
> >     public void ojbAdd(Object anObject)
> >     {
> >         super.getEntries().add(anObject);
> >     }
> >
> >     public void ojbAddAll(ManageableCollection otherCollection)
> >     {
> >         super.putAll((PersonMap) otherCollection);
> >     }
> >
> >     public Iterator ojbIterator()
> >     {
> >         return super.values().iterator();
> >     }
> > }
> >
> > And I declare the PersonMap class in repository as :
> >
> >    <class-descriptor
> >       class="com.dsc.nana.domain.organization.PersonMap"
> >       table="OJB_DMAP"
> >    >
> >       <field-descriptor
> >          name="id"
> >          column="ID"
> >          jdbc-type="INTEGER"
> >          primarykey="true"
> >          autoincrement="true"
> >       />
> >       <field-descriptor
> >          name="size"
> >          column="SIZE_"
> >          jdbc-type="INTEGER"
> >       />
> >       <collection-descriptor
> >          name="entries"
> >
element-class-ref="org.apache.ojb.odmg.collections.DMapEntry"
> >
> >
collection-class="org.apache.ojb.broker.util.collections.ManageableHashS
> > et"
> >       >
> >          <inverse-foreignkey field-ref="dmapId"/>
> >       </collection-descriptor>
> >    </class-descriptor>
> >
> > Then I get error messages as :
> >
> > 11:21:57,906 INFO  [STDOUT] [org.apache.ojb.broker.ta.NamingLocator]
> > INFO:
> > 11:21:57,921 INFO  [STDOUT] Init NamingLocator
> > 11:21:57,921 INFO  [STDOUT] [org.apache.ojb.broker.ta.NamingLocator]
> > INFO:
> > 11:21:57,937 INFO  [STDOUT] Properties for creating the initial
context:
> > null
> > 11:21:58,453 INFO  [STDOUT] [org.apache.ojb.odmg.TransactionImpl]
ERROR:
> > 11:21:58,453 INFO  [STDOUT] Locking obj
> > [EMAIL PROTECTED] with lock mode 1
failed
> > 11:21:58,484 INFO  [STDOUT] com.dsc.nana.domain.organization.Person
> > 11:21:58,484 ERROR [STDERR] java.lang.ClassCastException:
> > com.dsc.nana.domain.organization.Person
> > 11:21:58,500 ERROR [STDERR]     at
> > java.util.AbstractMap$4.next(AbstractMap.java:435)
> > 11:21:58,515 ERROR [STDERR]     at
> > org.apache.ojb.odmg.TransactionImpl.lockCollections(Unknown Source)
> > 11:21:58,531 ERROR [STDERR]     at
> > org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
> > 11:21:58,546 ERROR [STDERR]     at
> > org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
> > 11:21:58,578 ERROR [STDERR]     at
> >
org.apache.ojb.odmg.oql.OQLQueryImpl.performLockingIfRequired(Unknown
> > Source)
> > 11:21:58,593 ERROR [STDERR]     at
> > org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
> > 11:21:58,609 ERROR [STDERR]     at
> >
com.dsc.nana.persistence.JakartaOJBHelper.findByPrimaryKey(JakartaOJBHel
> > per.java:102)
> > 11:21:58,625 ERROR [STDERR]     at
> >
com.dsc.nana.persistence.PersistentObjectHelper.findByPrimaryKey(Persist
> > entObjectHelper.java:67)
> > 11:21:58,640 ERROR [STDERR]     at
> > com.dsc.nana.control.TestObjectBean.createPer
> >
> > Could you help me ?
> > Thanks advance.
> >
> > Dogie Tsai
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to