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


Java PersistenceBroker类代码示例

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


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


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