Hi Hans!

The point is not about wood in the tree,  (by the way very nice expression
:-))
It was me I was not understanding you.

What bd.updateCollectionReferences(formPartner) does is call
dao.updateCollectionReferences(formPartner),
and use the implementation of the interface DAO OjbPbDAO.
as all methods of this dao, dao.updateCollectionReferences(formPartner);
does resuming:

broker =
PersistenceBrokerFactory.defaultPersistenceBroker();

make his job

broker.close();





I understand that  you in your code don't close the broker ( broker.close()
).

I think you are using the cache ObjectCachePerBrokerImpl.

I never used this cache, but I think this cache exists just inside the
lifecycle of the broker. So if you use two different broker there are two
caches. That's why the cache of your broker doesn't see the update of the
mandragora broker.
Please confirm this, as I'm not so sure.

Now if you use other kind of cache the problem is solved (I think)
I think ObjectCacheDefaultImpl shoul work for you

Anyway of course this is a limitation of Mandragora. The original idea was
to hide Ojb to the user,  so Mandragora open use and close the broker. But
you are right. What goes on if you want to use your broker always?.

Well I will solve it in the next release. It is not so hard.

I think to do the following, tell me if you agree.

The OjbPbDAO doesn't do directly
broker =
PersistenceBrokerFactory.defaultPersistenceBroker();

but does : broker = ServiceLocator.getInstance().findBroker();
and the findBroker() give the broker.

Now I could add to the Service locator a private field
userBroker.
Then add a method setUserBroker(broker) or other like this.
and add a method closeUserBroker();

then in Mandragora.properties add an entry like this.

broker.useUserBroker = true  (or false of course)


In the method findbroker to put a condition that if the entry of
Mandragora.properties broker.useUserBroker is true, return the userbroker in
place of create a new broker.

And in all methods of OjbPbDAO , when they close the broker, put a
condition  that if broker.useUserBroker = true don't close, else close.

So it is user responsibility to create and close the broker.

With all of this your code should work. Of course remember to close the
broker.

Someone else (Armin? )agree with this?
I hope have been clear enough.

Anyway Hans, download the source, and have a look, so you can help. look at
the OjbDAO methods.
They just use Ojb so it is very easy and we can solve this together.

if you and Armin agree I start as soon as possible, even if I'm going on
travel tomorrow until October the 3th


Thanks
and regards

Alessandro







On 9/26/07, Hans Novak <[EMAIL PROTECTED]> wrote:
>
> Hi Allesandro,
>
> i think im stupid - or - how we in germany say: i dont see the wood for
> the trees ... ;-)
> im my (ojb) dao class i use
>
>
> public class PartnerFactoryCore {
>    private PersistenceBroker broker = null;
>    static Logger logger = Logger.getLogger("osf");
>
>    public PartnerFactoryCore() {
>        try {
>            broker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
>        } catch (Exception e) {
>            e.printStackTrace();
>            MsgBoxHn.msgBoxOK(e.getMessage().toString() +
> "\n\n\nProgrammende.");
>            System.exit(0);
>        }
>    }
>
>    ....
> }
>
>
> I use mandragora for example to store an object like this:
>
>
>
>    private void saveData(){
>        formPartner = getPartnerFromForm();
>        LOGGER.debug("Data Saving...");
>
>        //old way!!! - do not delete objects in the collection tree
>        //partnerFactoryCore.store(formPartner);  //from
>
>        // new Way with mandragora
>        try {
>            BD bd =
> ServiceLocator.getInstance
> ().getManagerBD("BDFactoryDefaultClass","StandardBDDefaultClass");
>            bd.updateCollectionReferences(formPartner);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>
>        LOGGER.debug(formPartner.toString(0));
>    }
>
>
>
> how can i put this 2 things together ?
>
>
> Hans
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to