Examples of PersistenceBroker


Examples of org.apache.ojb.broker.PersistenceBroker

        // can't find local bound object
        if(entry == null)
        {
            try
            {
                PersistenceBroker broker = tx.getBroker();
                // build Identity to lookup entry
                Identity oid = broker.serviceIdentity().buildIdentity(NamedEntry.class, key);
                entry = (NamedEntry) broker.getObjectByIdentity(oid);
            }
            catch(Exception e)
            {
                log.error("Can't materialize bound object for key '" + key + "'", e);
            }
View Full Code Here

Examples of org.apache.ojb.broker.PersistenceBroker

    }

    public void bind(Object object, String name) throws ObjectNameNotUniqueException
    {
        boolean useIdentity = true;
        PersistenceBroker broker = tx.getBroker();
        ClassDescriptor cld = null;
        try
        {
            cld = broker.getClassDescriptor(ProxyHelper.getRealClass(object));
        }
        catch(PersistenceBrokerException e)
        {
        }

        // if null a non-persistent capable object was specified
        if(cld == null)
        {
            useIdentity = false;
            if(!(object instanceof Serializable))
            {
                throw new ClassNotPersistenceCapableException(
                        "Can't bind named object, because it's not Serializable. Name=" + name + ", object=" + object);
            }
        }
        else
        {
            RuntimeObject rt = new RuntimeObject(object, tx);
            // if the object is already persistet, check for read
            // lock to make sure
            // that the used object is a valid version
            // else persist the specified named object
            if(!rt.isNew())
            {
                tx.lockAndRegister(rt, Transaction.READ, tx.getRegistrationList());
            }
            else
            {
                tx.makePersistent(rt);
            }
        }
        NamedEntry oldEntry = localLookup(name);
        if(oldEntry == null)
        {
            Identity oid = broker.serviceIdentity().buildIdentity(NamedEntry.class, name);
            oldEntry = (NamedEntry) broker.getObjectByIdentity(oid);
        }
        if(oldEntry != null)
        {
            throw new ObjectNameNotUniqueException("The name of the specified named object already exist, name=" + name);
        }
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.