本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
示例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);
}
}
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}