当前位置: 首页>>代码示例>>Java>>正文


Java PersistenceBroker.store方法代码示例

本文整理汇总了Java中org.apache.ojb.broker.PersistenceBroker.store方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceBroker.store方法的具体用法?Java PersistenceBroker.store怎么用?Java PersistenceBroker.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ojb.broker.PersistenceBroker的用法示例。


在下文中一共展示了PersistenceBroker.store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performInsert

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Have to be performed after the "normal" objects be written
 * to DB and after method {@link #performDeletion()}.
 */
public void performInsert()
{
    if(insertMap == null)
        return;
    else
    {
        PersistenceBroker broker = tx.getBroker();
        Iterator it = insertMap.values().iterator();
        while(it.hasNext())
        {
            NamedEntry namedEntry = (NamedEntry) it.next();
            namedEntry.prepareForStore(broker);
            broker.store(namedEntry, ObjectModification.INSERT);
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:NamedRootsMap.java

示例2: insert

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
* @see com.sun.jdori.StoreManager#insert(BitSet, BitSet, StateManagerInternal)
*/
public synchronized int insert(
    BitSet loadedFields,
    BitSet dirtyFields,
    StateManagerInternal sm)
{

    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); 
    }
    dirtyFields.xor(dirtyFields);
    return StateManagerInternal.FLUSHED_COMPLETE;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:24,代码来源:OjbStoreManager.java

示例3: update

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
* @see com.sun.jdori.StoreManager#update(BitSet, BitSet, StateManagerInternal)
*/
public synchronized int update(
    BitSet loadedFields,
    BitSet dirtyFields,
    StateManagerInternal sm)
{

    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); 
    }
    dirtyFields.xor(dirtyFields);
    return StateManagerInternal.FLUSHED_COMPLETE;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:25,代码来源:OjbStoreManager.java

示例4: testObjectCacheDefaultImplTimeout

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void testObjectCacheDefaultImplTimeout() throws Exception
{
    TestObjectDefaultCache obj = new TestObjectDefaultCache();
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    try
    {
        broker.beginTransaction();
        broker.store(obj);
        broker.commitTransaction();

        Identity oid = new Identity(obj, broker);
        obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
        assertNotNull(obj);

        Thread.sleep(5000);
        obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
        assertNull(obj);
    }
    finally
    {
        if(broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:24,代码来源:ObjectCacheTest.java

示例5: insertNewArticlesStress

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * A resource cumbering insert-method implementation,
 * this was used to test implementation.
 */
public void insertNewArticlesStress(PerfArticle[] arr) throws Exception
{
    for (int i = 0; i < arr.length; i++)
    {
        PersistenceBroker broker = null;
        try
        {
            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            broker.beginTransaction();
            broker.store(arr[i]);
            broker.commitTransaction();
        }
        finally
        {
            if (broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:OJBPerfTest.java

示例6: insertNewArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * A performance optimized insert-method implementation,
 * used to test performance.
 */
public void insertNewArticles(PerfArticle[] arr) throws Exception
{
    PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker.serviceConnectionManager().setBatchMode(true);
        broker.beginTransaction();
        for (int i = 0; i < arr.length; i++)
        {
            broker.store(arr[i], ObjectModification.INSERT);
        }
        broker.commitTransaction();
    }
    finally
    {
        if (broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:24,代码来源:OJBPerfTest.java

示例7: updateArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void updateArticles(PerfArticle[] arr) throws Exception
{
    PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker.serviceConnectionManager().setBatchMode(true);
        broker.beginTransaction();
        for (int i = 0; i < arr.length; i++)
        {
            broker.store(arr[i], ObjectModification.UPDATE);
            // broker.store(arr[i]);
        }
        broker.commitTransaction();
    }
    finally
    {
        if (broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:OJBPerfTest.java

示例8: updateArticlesStress

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void updateArticlesStress(PerfArticle[] arr) throws Exception
{
    for (int i = 0; i < arr.length; i++)
    {
        PersistenceBroker broker = null;
        try
        {
            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            broker.beginTransaction();
            broker.store(arr[i]);
            broker.commitTransaction();
        }
        finally
        {
            if (broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:OJBPerfTest.java

示例9: testMultipleAutoincrement

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
     * Test support for classes with multiple autoincrement
     * fields - e.g. see repository for {@link Repository.SMKey}
     */
    public void testMultipleAutoincrement()
    {
        String MESSAGE = "Autoincrement field was not incremented: ";
        String name = "my test key " + System.currentTimeMillis();
        Repository.SMKey key = new Repository.SMKey();
        key.setName(name);
        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker.beginTransaction();
        broker.store(key);
        broker.commitTransaction();
        assertEquals("Value was not store: " + key, name, key.getName());
        assertNotNull(MESSAGE + key, key.getIntegerKey());
        assertTrue(MESSAGE + key, (key.getIntKey() != 0));
        assertNotNull(MESSAGE + key, key.getLongKey());
        assertNotNull(MESSAGE + key, key.getStringKey());
//        System.out.println("## SMKey: \n"+key);

        Criteria cr = new Criteria();
        cr.addEqualTo("name", name);
        Query query = new QueryByCriteria(Repository.SMKey.class, cr);
        key = (Repository.SMKey) broker.getObjectByQuery(query);

        assertEquals("Value was not store: ", name, key.getName());
        assertNotNull(MESSAGE + key, key.getIntegerKey());
        assertTrue(MESSAGE + key, (key.getIntKey() != 0));
        assertNotNull(MESSAGE + key, key.getLongKey());
        assertNotNull(MESSAGE + key, key.getStringKey());
//        System.out.println("## SMKey: \n"+key);

        broker.close();
    }
 
开发者ID:KualiCo,项目名称:ojb,代码行数:36,代码来源:SequenceManagerTest.java

示例10: testMaxKeySearch2

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Test the max id search used in the standard sequence manager
 * implementations.
 */
public void testMaxKeySearch2()
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    // find max from classes using the same table
    broker.beginTransaction();
    broker.store(new ObjectRepository.A());
    broker.store(new ObjectRepository.B());
    broker.store(new ObjectRepository.B1());
    broker.store(new ObjectRepository.C());
    broker.store(new ObjectRepository.D());
    broker.commitTransaction();
    long[] result = new long[5];
    FieldDescriptor field = broker.getClassDescriptor(ObjectRepository.A.class).getAutoIncrementFields()[0];
    result[0] = SequenceManagerHelper.getMaxForExtent(broker, field);
    field = broker.getClassDescriptor(ObjectRepository.B.class).getAutoIncrementFields()[0];
    result[1] = SequenceManagerHelper.getMaxForExtent(broker, field);
    field = broker.getClassDescriptor(ObjectRepository.C.class).getAutoIncrementFields()[0];
    result[2] = SequenceManagerHelper.getMaxForExtent(broker, field);
    field = broker.getClassDescriptor(ObjectRepository.D.class).getAutoIncrementFields()[0];
    result[3] = SequenceManagerHelper.getMaxForExtent(broker, field);
    field = broker.getClassDescriptor(ObjectRepository.B1.class).getAutoIncrementFields()[0];
    result[4] = SequenceManagerHelper.getMaxForExtent(broker, field);
    broker.close();

    for (int i = 0; i < result.length; i++)
    {
        for (int k = 0; k < result.length; k++)
        {
            if (!(result[i] == result[k]))
            {
                fail(DEF_FAIL_MESSAGE);
            }
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:40,代码来源:SequenceManagerTest.java

示例11: testMassStoreOfObjects

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void testMassStoreOfObjects()
{
    int outerLoops = 10;
    int innerLoops = 30;
    String name = "Name_" + System.currentTimeMillis();

    Repository.SMKey key = null;
    for (int i = outerLoops - 1; i >= 0; i--)
    {
        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        try
        {
            broker.beginTransaction();
            for (int j = innerLoops - 1; j >= 0; j--)
            {
                key = new Repository.SMKey();
                key.setName(name);
                broker.store(key);
            }
            broker.commitTransaction();
        }
        finally
        {
            if(broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:28,代码来源:SequenceManagerTest.java

示例12: testObjectCacheDefaultImpl

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void testObjectCacheDefaultImpl() throws Exception
{
    String name = "testObjectCacheDefaultImpl_"+System.currentTimeMillis();
    TestObjectDefaultCache obj = new TestObjectDefaultCache();
    obj.setName(name);
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    try
    {
        broker.beginTransaction();
        broker.store(obj);
        broker.commitTransaction();

        Identity oid = new Identity(obj, broker);
        obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
        assertNotNull(obj);
        assertEquals(name, obj.getName());

        // modify name
        String new_name = "modified_"+name;
        obj.setName(new_name);
        obj = (TestObjectDefaultCache) broker.getObjectByIdentity(oid);
        assertNotNull(obj);
        assertEquals("current version of cache should return the modified object", new_name, obj.getName());

        broker.removeFromCache(oid);
        obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
        assertNull("Should be removed from cache", obj);
        obj = (TestObjectDefaultCache) broker.getObjectByIdentity(oid);
        assertNotNull(obj);
        assertEquals("Should return the unmodified object", name, obj.getName());
    }
    finally
    {
        if(broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:37,代码来源:ObjectCacheTest.java

示例13: testPerClassCache

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Test per class ObjectCache declaration. 'TestObjectEmptyCache'
 * class metadata declare an 'empty ObjectCache' implementation
 * as cache, CacheObject use the default ObjectCache implementation.
 * Thus we should found 'CacheObject' instance in cache, but NOT found
 * 'TestObjectEmptyCache' instance.
 */
public void testPerClassCache() throws Exception
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    JdbcConnectionDescriptor jcd = broker.serviceConnectionManager().getConnectionDescriptor();
    if(jcd.getObjectCacheDescriptor().getObjectCache().equals(ObjectCacheEmptyImpl.class))
    {
        ojbSkipTestMessage("Doesn't work with " + ObjectCacheEmptyImpl.class + " as default cache.");
        return;
    }
    String name = "testPerClassCache_" + System.currentTimeMillis();

    TestObjectEmptyCache obj = new TestObjectEmptyCache();
    obj.setName(name);
    CacheObject dummy = new CacheObject();
    dummy.setName(name);

    try
    {
        broker.beginTransaction();
        broker.store(obj);
        broker.store(dummy);
        broker.commitTransaction();

        Identity obj_oid = new Identity(obj, broker);
        Identity dummy_oid = new Identity(dummy, broker);
        ObjectCache cache = broker.serviceObjectCache();
        Object ret_obj = cache.lookup(obj_oid);
        Object ret_dummy = cache.lookup(dummy_oid);
        assertNotNull(ret_dummy);
        assertNull(ret_obj);
    }
    finally
    {
        if (broker != null && broker.isInTransaction()) broker.abortTransaction();
        if (broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:45,代码来源:ObjectCacheTest.java

示例14: storeObjects

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
protected List storeObjects(PersistenceBroker broker, List objects)
{
    for (Iterator it = objects.iterator(); it.hasNext();)
    {
        broker.store(it.next());
    }
    return objects;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:9,代码来源:PBSessionBean.java

示例15: storeObjects

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
private Collection storeObjects(PersistenceBroker broker, Collection objects)
{
    for (Iterator it = objects.iterator(); it.hasNext();)
    {
        broker.store(it.next());
    }
    return objects;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:9,代码来源:PersonArticleManagerPBBean.java


注:本文中的org.apache.ojb.broker.PersistenceBroker.store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。