• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PersistenceBroker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: nextAvailableSequenceNumber

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
private Long nextAvailableSequenceNumber(String sequenceName, Class clazz) {
       ModuleService moduleService = getKualiModuleService().getResponsibleModuleService(clazz);
       if ( moduleService == null )
       	throw new ConfigurationException("moduleService is null");
       	        	
       ModuleConfiguration moduleConfig = moduleService.getModuleConfiguration();
       if ( moduleConfig == null )
       	throw new ConfigurationException("moduleConfiguration is null");

       String dataSourceName = moduleConfig.getDataSourceName();

       if (StringUtils.isEmpty(dataSourceName)) {
           return nextAvailableSequenceNumber(sequenceName);
       } else {
           PBKey key = new PBKey(dataSourceName);
           PersistenceBroker broker = OjbFactoryUtils.getPersistenceBroker(key, false);

           if (broker != null) {
               return getDbPlatform().getNextValSQL(sequenceName, broker);
           } else {
               throw new ConfigurationException("PersistenceBroker is null");
           }
       }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:SequenceAccessorDaoJdbc.java


示例2: getAllObjects

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * Return all objects for the given class.
 */
public Collection getAllObjects(Class target)
{
    PersistenceBroker broker = getBroker();
    Collection result;
    try
    {
        Query q = new QueryByCriteria(target);
        result = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:PBBaseBeanImpl.java


示例3: copy

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * If users want to implement clone on all their objects, we can use this
 * to make copies. This is hazardous as user may mess it up, but it is also
 * potentially the fastest way of making a copy.
 *
 * Usually the OjbCloneable interface should just be delegating to the clone()
 * operation that the user has implemented.
 *
 * @see org.apache.ojb.otm.copy.ObjectCopyStrategy#copy(Object)
 *
 */
public Object copy(Object obj, PersistenceBroker broker)
		throws ObjectCopyException
{
	if (obj instanceof OjbCloneable)
	{
		try
		{
			return ((OjbCloneable) obj).ojbClone();
		}
		catch (Exception e)
		{
			throw new ObjectCopyException(e);
		}
	}
	else
	{
		throw new ObjectCopyException("Object must implement OjbCloneable in order to use the"
									  + " CloneableObjectCopyStrategy");
	}
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:32,代码来源:CloneableObjectCopyStrategy.java


示例4: getPersons

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getPersons(String firstname, String lastname)
{
    PersistenceBroker broker = getBroker();
    Criteria criteria = new Criteria();
    if (firstname != null) criteria.addEqualTo("firstname", firstname);
    if (lastname != null) criteria.addEqualTo("firstname", lastname);
    Query q = new QueryByCriteria(PersonVO.class);
    Collection result = broker.getCollectionByQuery(q);
    broker.close();
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:15,代码来源:PersonManagerPBBean.java


示例5: testLookupPB1

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * test to check PB create with PBKey
 */
public void testLookupPB1()
{
    PBKey key1 = new PBKey(TestHelper.DEF_JCD_ALIAS);
    PBKey key2 = new PBKey(TestHelper.DEF_JCD_ALIAS, TestHelper.DEF_USER, TestHelper.DEF_PASSWORD);
    PBKey key3 = new PBKey(TestHelper.FAR_AWAY_JCD_ALIAS);
    Query query = QueryFactory.newQuery(TEST_CLASS, new Criteria());

    PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(key1);
    broker.getCount(query);
    broker.close();

    broker = PersistenceBrokerFactory.createPersistenceBroker(key2);
    broker.getCount(query);
    broker.close();

    broker = PersistenceBrokerFactory.createPersistenceBroker(key3);
    broker.getCount(query);
    broker.close();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:MetadataTest.java


示例6: internalCleanup

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * In managed environment do internal close the used connection
 */
private void internalCleanup()
{
    if(hasBroker())
    {
        PersistenceBroker broker = getBroker();
        if(log.isDebugEnabled())
        {
            log.debug("Do internal cleanup and close the internal used connection without" +
                    " closing the used broker");
        }
        ConnectionManagerIF cm = broker.serviceConnectionManager();
        if(cm.isInLocalTransaction())
        {
            /*
            arminw:
            in managed environment this call will be ignored because, the JTA transaction
            manager control the connection status. But to make connectionManager happy we
            have to complete the "local tx" of the connectionManager before release the
            connection
            */
            cm.localCommit();
        }
        cm.releaseConnection();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:29,代码来源:J2EETransactionImpl.java


示例7: SequenceManagerHandle

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public SequenceManagerHandle(PersistenceBroker broker, Class targetClass, int loops)
{
    this.broker = broker;
    this.targetClass = targetClass;
    this.field = broker.getClassDescriptor(targetClass).getAutoIncrementFields()[0];
    if(field == null)
    {
        String error = "No autoincrement field found for class "+targetClass+
        " using class descriptor from given broker: "+broker.getClassDescriptor(targetClass);
        throw new PersistenceBrokerException(error);
    }
    this.loops = loops;
    resultList = new ArrayList();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:15,代码来源:SequenceManagerHandle.java


示例8: execute

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public void execute(PersistenceBroker broker)
{
    if(isUnlink)
    {
        broker.serviceBrokerHelper().unlink(source, (CollectionDescriptor) ord, referenceToLink);
    }
    else
    {
        broker.serviceBrokerHelper().link(source, (CollectionDescriptor) ord, referenceToLink);
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:12,代码来源:LinkEntryOneToN.java


示例9: execute

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public void execute(PersistenceBroker broker)
{
    if(isUnlink)
    {
        broker.serviceBrokerHelper().unlink(referenceToLink, ord, false);
    }
    else
    {
        broker.serviceBrokerHelper().link(referenceToLink, ord, false);
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:12,代码来源:LinkEntryOneToOne.java


示例10: buildObjectImage

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * buildObjectImage() will return the image of the Object.
 */
private Map buildObjectImage(PersistenceBroker broker) throws PersistenceBrokerException
{
    Map imageMap = new HashMap();
    ClassDescriptor cld = broker.getClassDescriptor(getObject().getClass());
    //System.out.println("++++ build image: " + getObject());
    // register 1:1 references in image
    buildImageForSingleReferences(imageMap, cld);
    // put object values to image map
    buildImageForFields(imageMap, cld);
    // register 1:n and m:n references in image
    buildImageForCollectionReferences(imageMap, cld);
    return imageMap;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:17,代码来源:ObjectEnvelope.java


示例11: 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


示例12: getDBObjectCountWithNewPB

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
protected int getDBObjectCountWithNewPB(PBKey pbKey, Class target) throws Exception
{
    PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey);
    Criteria c = new Criteria();
    Query q = new QueryByCriteria(target, c);
    int count = broker.getCount(q);
    broker.close();
    return count;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:10,代码来源:MultiDBUsageTest.java


示例13: changeReferenceSetting

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public void changeReferenceSetting(PersistenceBroker broker, Class clazz,
                                           String referenceField, boolean autoRetrieve,
                                           int autoUpdate, int autoDelete, boolean useProxy)
        {
            ClassDescriptor cld = broker.getClassDescriptor(clazz);
            ObjectReferenceDescriptor ref = cld.getCollectionDescriptorByName(referenceField);
            ref = cld.getCollectionDescriptorByName(referenceField);
            if(ref == null) ref = cld.getObjectReferenceDescriptorByName(referenceField);
            if(ref == null)
            {
                throw new OJBRuntimeException("Given field " + referenceField + " does not match a reference in " + clazz);
            }

            prepareSetting(ref, cld, clazz, referenceField);

            ref.setLazy(useProxy);
            ref.setCascadeRetrieve(autoRetrieve);
            ref.setCascadingStore(autoUpdate);
            ref.setCascadingDelete(autoDelete);

//            System.out.println("old settings: " + oldRef.toXML());
//            System.out.println("new settings: " + ref.toXML());
        }
 
开发者ID:KualiCo,项目名称:ojb,代码行数:24,代码来源:OJBTestCase.java


示例14: getArticleByIdentity

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public PerfArticle getArticleByIdentity(Long articleId) throws Exception
        {
//            m_tx.setImplicitLocking(false);
//            m_tx.begin();
//            OQLQuery query = odmg.newOQLQuery();
//            String sql = "select allArticles from " + PerfArticleImpl.class.getName() +
//                    " where articleId=$";
//            query.create(sql);
//            query.bind(articleId);
//            List result = (List) query.execute();
//            m_tx.commit();
//            return (PerfArticle) result.get(0);
// use OJB's extension for faster Identity lookup
            PerfArticle result;
            m_tx.setImplicitLocking(false);
            m_tx.begin();
            PersistenceBroker pb = m_tx.getBroker();
            result = (PerfArticle) pb.getObjectByIdentity(pb.serviceIdentity().buildIdentity(PerfArticleImpl.class, articleId));
            m_tx.commit();
            return result;
        }
 
开发者ID:KualiCo,项目名称:ojb,代码行数:22,代码来源:OJBPerfTest.java


示例15: getElementsExtentClass

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
private Class getElementsExtentClass(PersistenceBroker broker) throws PersistenceBrokerException
{
    // we ll have to compute the most general extent class here !!!
    DListEntry entry = (DListEntry) elements.get(0);
    Class elementsClass = entry.getRealSubject().getClass();
    Class extentClass = broker.getTopLevelClass(elementsClass);
    return extentClass;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:9,代码来源:DSetImpl.java


示例16: SequenceManagerHighLowImpl

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public SequenceManagerHighLowImpl(PersistenceBroker broker)
{
    super(broker);
    Long start = SequenceManagerHelper.getSeqStart(getConfigurationProperties());
    sequenceStart = start != null ? start.longValue() : 1;
    grabSize = Integer.parseInt(getConfigurationProperty(PROPERTY_GRAB_SIZE, "20"));
    useGlobalSequenceIdentities = Boolean.getBoolean(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_ID, "false"));
    // support for deprecated properties
    long globalSequenceStart = Long.parseLong(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_START, "1"));
    if(useGlobalSequenceIdentities && globalSequenceStart > sequenceStart)
    {
        sequenceStart = globalSequenceStart;
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:15,代码来源:SequenceManagerHighLowImpl.java


示例17: testDatabaseSequenceGeneration

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * This test only works, when using
 * {@link org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl}
 * for sequence generation.
 */
public void testDatabaseSequenceGeneration() throws Exception
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    SequenceManager sm = SequenceManagerFactory.getSequenceManager(broker);
    if (!(sm instanceof SequenceManagerNextValImpl))
    {
        System.out.println("This test only works for SeqMan implementations using "
                + SequenceManagerNextValImpl.class + " Skip test case.");
        broker.close();
        return;
    }
    int count = 0;
    FieldDescriptor idFld = broker.getClassDescriptor(
            Repository.SMDatabaseSequence.class).getAutoIncrementFields()[0];
    for (int i = 0; i < 10; i++)
    {
        Integer val = (Integer) sm.getUniqueValue(idFld);
        count += val.intValue();
        System.err.println("count " + count);
    }
    assertFalse("No keys generated", count == 0);
    broker.close();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:29,代码来源:SequenceManagerTest.java


示例18: afterStore

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * @see org.apache.ojb.broker.ManageableCollection#afterStore(PersistenceBroker broker)
 */
public void afterStore(PersistenceBroker broker) throws PersistenceBrokerException
{
    // make sure allObjectsToBeRemoved does not contain
    // any instances that got re-added to the list
    allObjectsToBeRemoved.removeAll(this);

    Iterator iter = allObjectsToBeRemoved.iterator();
    while (iter.hasNext())
    {
        Object obj = iter.next();
        ClassDescriptor cld = broker.getClassDescriptor(obj.getClass());
        if (broker.serviceBrokerHelper().assertValidPkForDelete(cld, obj))
        {    
            broker.delete(obj);
        }    
    }
    allObjectsToBeRemoved.clear();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:22,代码来源:RemovalAwareCollection.java


示例19: buildNextSequence

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
/**
 * Calls the stored procedure stored procedure throws an
 * error if it doesn't exist.
 * @param broker
 * @param cld
 * @param sequenceName
 * @return
 * @throws LookupException
 * @throws SQLException
 */
protected long buildNextSequence(PersistenceBroker broker, ClassDescriptor cld, String sequenceName)
        throws LookupException, SQLException, PlatformException
{
    CallableStatement cs = null;
    try
    {
        Connection con = broker.serviceConnectionManager().getConnection();
        cs = getPlatform().prepareNextValProcedureStatement(con, PROCEDURE_NAME, sequenceName);
        cs.executeUpdate();
        return cs.getLong(1);
    }
    finally
    {
        try
        {
            if (cs != null)
                cs.close();
        }
        catch (SQLException ignore)
        {
            // ignore it
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:35,代码来源:SequenceManagerStoredProcedureImpl.java


示例20: readArticlesByCursor

import org.apache.ojb.broker.PersistenceBroker; //导入依赖的package包/类
public Collection readArticlesByCursor(String articleName) throws Exception
{
    Criteria c = new Criteria();
    c.addLike("articleName", articleName);
    Query q = new QueryByCriteria(PerfArticleImpl.class, c);

    Collection col = null;
    PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        col = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return col;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:20,代码来源:OJBPerfTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DatabaseDataSourceConnection类代码示例发布时间:2022-05-22
下一篇:
Java BufferAllocator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap