Alessandro Colantoni wrote:
I think you are using the cache ObjectCachePerBrokerImpl.
Or the recommended two-level cache which has a session cache too.
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.
If OjbPbDAO can differ between user-PB and new-PB this should work, else a user got problems when using both strategies - e.g. most times inject a user-PB, but from time to time using the ServiceLocator without injection of a user-PB (e.g. with default settings, based on the current PBKey, to perform a simple query).
In general, I think implementing ServiceLocator and DAO as singletons cause some drawbacks, because singletons make it impossible to use different PBKey (e.g. different databases) in the same web-project/application or in a multi-threaded environment. If ServiceLocator isn't a singleton it can have a state (e.g. the user can specify a PBKey to force creation of specific PB instances).
regards, Armin
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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
