hi, all.

   from your email, i think you can help me.
Thanks advance.

   I encountered a problem as follows:

class myList and myEntry has a 1:n relationship
each myList has a collection of myEntry(s)

Class myList
{
  ...
  List entries;
  ...
}

Class myEntry
{
  String entryName;
  ...
}

I store them in two DB tables as

CREATE TABLE list
(
  id  varchar(20) not null,
  ...

  primary key(id)
);


CREATE TABLE entry
(
  id         varchar(20) not null,
  list_id    varchar(20),
  name       varchar(100),
  ...

  primary key(id),
  foreign key(list_id) references list(id)
);


in reporsitory.xml:

<!-- ====  List  ==== -->

<class-descriptor
      class="myList"
      table="list"
>
  <field-descriptor
     name="id"
     column="id"
     jdbc-type="VARCHAR"
     primarykey="true"
     autoincrement="true"
  />

  <collection-descriptor
      name="entries"

collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList
"
      element-class-ref="myEntry"
      auto-retrieve="true"
      auto-update="true"
      auto-delete="true"
      >
      <inverse-foreignkey field-ref="listId"/>
  </collection-descriptor>

</class-descriptor>


<!-- ====  Entry  ==== -->

<class-descriptor
      class="myEntry"
      table="entry"
>
  <field-descriptor
     name="id"
     column="id"
     jdbc-type="VARCHAR"
     primarykey="true"
     autoincrement="true"
  />
  <field-descriptor
     name="listId"
     column="list_id"
     jdbc-type="VARCHAR"
     access="anonymous"
  />
  <field-descriptor
     name="name"
     column="name"
     jdbc-type="VARCHAR"
  />
</class-descriptor>


in this way, listPersisiter.store() and get() can automatically
store and retrieve entry.

but when i retrieve myList, and remove an entry from
myList.entries, and store back, it can not automatically
delete the entry in DB which have been removed from
myList.entries.

is ojb can not support this kind of operation?

i think in ojb must have a way to automatically do these things.

thanks!



----- Original Message ----- 
From: "Michael Mogley" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, December 01, 2003 4:50 PM
Subject: Re: does PersistenceBroker.getCollectionByQuery use the cache?


> Thanks Thomas.  Actually, right after I posted, the problem seems to have
> gone away.  In my webapp, I am actually being careful not to maintain
copies
> of the domain objects, as this would lead to precisely the issue you
> describe.
>
> Michael
>
> ----- Original Message ----- 
> From: "Thomas Mahler" <[EMAIL PROTECTED]>
> To: "OJB Users List" <[EMAIL PROTECTED]>
> Sent: Sunday, November 30, 2003 11:42 PM
> Subject: Re: does PersistenceBroker.getCollectionByQuery use the cache?
>
>
> > Hi Michael,
> >
> > OJB puts all loaded entities (also those in collection attributes) into
> > the cache.
> > So if you can make sure that the updates are executed on exactly the
> > same instances (and not a copy) of the photos stored in your collection
> > everything should be fine.
> >
> > But this is exactly the problem! in webapplications you typically have a
> > some kind of (copying) data transfer between the jsp pages and the
> > domain model. If you are using copies somewhere, your changes to those
> > copies will be stored by the broker, but they are reflected in the
cache.
> >
> > Please call broker.clearCache() before  loading the complete album in
> > albumPhotos.jsp. If I am right it should now display all photos with the
> > correct information.
> >
> > cheers,
> > Thomas
> >
> > Michael Mogley wrote:
> > > In my webapp, I've run across what may be a bug in Ojb.
> > >
> > > I have an Album class with a collection of Photos.
> > >
> > > I also have a jsp page, photoEdit.jsp,  that retrieves a specific
> > > Photo by identity, modifies it, then does PersistenceBroker.store.
> > >
> > > I have another page, albumPhotos.jsp, that lists all the photos in a
> > > given album along with some of their attributes.
> > >
> > > When I make a change in photoEdit.jsp to a given Photo, then go to
> > > albumPhotos.jsp to to list all the photos in the album, the Photo I
> > > changed is listed with the old attributes.
> > >
> > > I am using ObjectDefaultCacheImpl and the app initializes and keeps a
> > > reference to a single PersistenceBroker instance.
> > >
> > > It seems to me that when the Albums.photos collection attribute is
> > > being initialized, the elements in the collection are not being
> > > cached.
> > >
> > > Is this true?  If so, it seems this would be bug.
> > >
> > > Or could I doing something half-assed?
> > >
> > > Thanks in advance.
> > >
> > > Michael
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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]


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

Reply via email to