Examples of PersistenceBroker


Examples of org.apache.ojb.broker.PersistenceBroker

    /**
     * Used to get PB, when no tx is running.
     */
    private PersistenceBroker obtainBroker()
    {
        PersistenceBroker _broker;
        try
        {
            if (pbKey == null)
            {
                //throw new OJBRuntimeException("Not possible to do action, cause no tx runnning and no PBKey is set");
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

    {

        try
        {
            logger.debug("OjbStoreManager.insert");
            PersistenceBroker broker = connector.getBroker();
            Object instance = sm.getObject();
            broker.store(instance, ObjectModificationDefaultImpl.INSERT);
        }
        catch (Exception ex)
        {
            throw new OjbStoreFatalInternalException(getClass(), "insert", ex);
        }
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

    {

        try
        {
          logger.debug("OjbStoreManager.update");
            PersistenceBroker broker = connector.getBroker();
            fetch(sm, null);
            Object instance = sm.getObject();
            broker.store(instance, ObjectModificationDefaultImpl.UPDATE);
        }
        catch (Exception ex)
        {
            throw new OjbStoreFatalInternalException(getClass(), "update", ex);
        }
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

    /**
    * @see com.sun.jdori.StoreManager#fetch
    */
    public synchronized void fetch(StateManagerInternal sm, int fieldNums[])
    {
        PersistenceBroker broker = connector.getBroker();
        try
        {
          Object instance = sm.getObject();
            Identity oid = (Identity) sm.getInternalObjectId();
            if (oid == null)
            {               
                oid = new Identity(instance,broker);
            }
            broker.removeFromCache(instance);
            PersistenceCapable pc = (PersistenceCapable) broker.getObjectByIdentity(oid);

            JDOClass jdoClass = Helper.getJDOClass(pc.getClass());
            if (fieldNums == null)
            {
                fieldNums = jdoClass.getManagedFieldNumbers();
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

    public synchronized Extent getExtent(
        Class pcClass,
        boolean subclasses,
        PersistenceManagerInternal pm)
    {
        PersistenceBroker broker = connector.getBroker();
        return new OjbExtent(pcClass, broker, pm);
    }
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

        PBCapsule handle = new PBCapsule(pbKey, tx);
        DList result;
        try
        {
            PersistenceBroker broker = handle.getBroker();
            Criteria allElementsCriteria = this.getPkCriteriaForAllElements(broker);
            // join selection of elements with predicate criteria:
            allElementsCriteria.addAndCriteria(pCrit);

            Class clazz = null;
            try
            {
                clazz = this.getElementsExtentClass(broker);
            }
            catch (PersistenceBrokerException e)
            {
                getLog().error(e);
                throw new ODMGRuntimeException(e.getMessage());
            }
            Query q = new QueryByCriteria(clazz, allElementsCriteria);
            if (getLog().isDebugEnabled()) getLog().debug(q.toString());

            result = null;
            try
            {
                result = (DList) broker.getCollectionByQuery(DListImpl.class, q);
            }
            catch (PersistenceBrokerException e)
            {
                getLog().error("Query failed", e);
                throw new OJBRuntimeException(e);
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

     * @param reuse When all registered objects be re-used after writing to
     * DB set <em>true</em>, else set <em>false</em> to improve performance.
     */
    public void writeObjects(boolean reuse) throws TransactionAbortedException, LockNotGrantedException
    {
        PersistenceBroker broker = transaction.getBroker();
        ConnectionManagerIF connMan = broker.serviceConnectionManager();
        boolean saveBatchMode = connMan.isBatchMode();

        try
        {
            if(log.isDebugEnabled())
            {
                log.debug(
                        "PB is in internal tx: "
                                + broker.isInTransaction()
                                + "  broker was: "
                                + broker);
            }
            // all neccessary db operations are executed within a PersistenceBroker transaction:
            if(!broker.isInTransaction())
            {
                log.error("PB associated with current odmg-tx is not in tx");
                throw new TransactionAbortedException("Underlying PB is not in tx, was begin call done before commit?");
            }

View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

    {
        if (isOpen())
        {
            throw new DatabaseOpenException("Database is already open");
        }
        PersistenceBroker broker = null;
        try
        {
            if (name == null)
            {
                log.info("Given argument was 'null', open default database");
                broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            }
            else
            {
                broker = PersistenceBrokerFactory.createPersistenceBroker(
                        BrokerHelper.extractAllTokens(name));
            }
            pbKey = broker.getPBKey();
            isOpen = true;
            //register opened database
            odmg.registerOpenDatabase(this);
            if (log.isDebugEnabled()) log.debug("Open database using PBKey " + pbKey);
        }
        catch (PBFactoryException ex)
        {
            log.error("Open database failed: " + ex.getMessage(), ex);
            throw new DatabaseNotFoundException(
                    "OJB can't open database " + name + "\n" + ex.getMessage());
        }
        finally
        {
            // broker must be immediately closed
            if (broker != null)
            {
                broker.close();
            }
        }
    }
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

        linkEntryList.add(entry);
    }

    private void performLinkEntries()
    {
        PersistenceBroker broker = getBroker();
        for(int i = 0; i < linkEntryList.size(); i++)
        {
            LinkEntry linkEntry = (LinkEntry) linkEntryList.get(i);
            linkEntry.execute(broker);
        }
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

   * returns the LockEntry for the Writer of object obj.
   * If now writer exists, null is returned.
   */
  public LockEntry getWriter(Object obj)
  {
    PersistenceBroker broker = getBroker();
    Identity oid = new Identity(obj, broker);
   
        LockEntry result = null;
        try
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.