本文整理汇总了Java中org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException类的典型用法代码示例。如果您正苦于以下问题:Java ClassNotPersistenceCapableException类的具体用法?Java ClassNotPersistenceCapableException怎么用?Java ClassNotPersistenceCapableException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassNotPersistenceCapableException类属于org.apache.ojb.broker.metadata包,在下文中一共展示了ClassNotPersistenceCapableException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getClassDescriptor
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* @param persistableClass
* @return ClassDescriptor for the given Class
* @throws IllegalArgumentException
* if the given Class is null
* @throws ClassNotPersistableException
* if the given Class is unknown to OJB
*/
// Legacy OJB - no need for JPA equivalent
protected ClassDescriptor getClassDescriptor(Class persistableClass) {
if (persistableClass == null) {
throw new IllegalArgumentException("invalid (null) object");
}
ClassDescriptor classDescriptor = null;
DescriptorRepository globalRepository = getDescriptorRepository();
try {
classDescriptor = globalRepository.getDescriptorFor(persistableClass);
} catch (ClassNotPersistenceCapableException e) {
throw new ClassNotPersistableException("class '" + persistableClass.getName() + "' is not persistable", e);
}
return classDescriptor;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:PersistenceServiceStructureImplBase.java
示例2: getClassDescriptor
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* Returns the OJB class descriptor
*
* @param <E> an origin entry class
* @param persistableClass the class
* @return the class descriptor
*/
protected <E extends OriginEntryFull> ClassDescriptor getClassDescriptor(Class<E> persistableClass) {
if (persistableClass == null) {
throw new IllegalArgumentException("invalid (null) object");
}
ClassDescriptor classDescriptor = null;
DescriptorRepository globalRepository = getDescriptorRepository();
try {
classDescriptor = globalRepository.getDescriptorFor(persistableClass);
}
catch (ClassNotPersistenceCapableException e) {
throw new ClassNotPersistableException("class '" + persistableClass.getName() + "' is not persistable", e);
}
return classDescriptor;
}
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:24,代码来源:ReconciliationDaoOjb.java
示例3: createException
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
private ClassNotPersistenceCapableException createException(String msg, final Object objectToIdentify, final Exception e)
{
final String eol = SystemUtils.LINE_SEPARATOR;
if(msg == null)
{
msg = "Unexpected error:";
}
if(e != null)
{
return new ClassNotPersistenceCapableException(msg + eol +
"objectTopLevelClass=" + (m_objectsTopLevelClass != null ? m_objectsTopLevelClass.getName() : null) + eol +
"objectRealClass=" + (m_objectsRealClass != null ? m_objectsRealClass.getName() : null) + eol +
"pkValues=" + (m_pkValues != null ? ArrayUtils.toString(m_pkValues) : null) +
(objectToIdentify != null ? (eol + "object to identify: " + objectToIdentify) : ""), e);
}
else
{
return new ClassNotPersistenceCapableException(msg + eol +
"objectTopLevelClass=" + (m_objectsTopLevelClass != null ? m_objectsTopLevelClass.getName() : null) + eol +
"objectRealClass=" + (m_objectsRealClass != null ? m_objectsRealClass.getName() : null) + eol +
"pkValues=" + (m_pkValues != null ? ArrayUtils.toString(m_pkValues) : null) +
eol + "object to identify: " + objectToIdentify);
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:25,代码来源:Identity.java
示例4: instantiate
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* create a new instance of class clazz.
* first use the public default constructor.
* If this fails also try to use protected an private constructors.
* @param clazz the class to instantiate
* @return the fresh instance of class clazz
* @throws InstantiationException
*/
public static Object instantiate(Class clazz) throws InstantiationException
{
Object result = null;
try
{
result = ClassHelper.newInstance(clazz);
}
catch(IllegalAccessException e)
{
try
{
result = ClassHelper.newInstance(clazz, true);
}
catch(Exception e1)
{
throw new ClassNotPersistenceCapableException("Can't instantiate class '"
+ (clazz != null ? clazz.getName() : "null")
+ "', message was: " + e1.getMessage() + ")", e1);
}
}
return result;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:31,代码来源:ConstructorHelper.java
示例5: retrieveObjectForEditOrCopy
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.maintenance.Maintainable#retrieveObjectForEditOrCopy(MaintenanceDocument, java.util.Map)
*/
@Override
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
Object dataObject = null;
try {
dataObject = getLookupService().findObjectBySearch(getDataObjectClass(), dataObjectKeys);
} catch (ClassNotPersistenceCapableException ex) {
if (!document.getOldMaintainableObject().isExternalBusinessObject()) {
throw new RuntimeException("Data Object Class: "
+ getDataObjectClass()
+ " is not persistable and is not externalizable - configuration error");
}
// otherwise, let fall through
}
return dataObject;
}
开发者ID:aapotts,项目名称:kuali_rice,代码行数:21,代码来源:MaintainableImpl.java
示例6: retrieveCollectorDetailTableName
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* Retrieves the DB table name that's mapped to instances of CollectorDetail by finding the class descriptor name from the
* class descriptor respository
* @return the table name where collector details are saved to
* @see org.kuali.ole.gl.dataaccess.CollectorDetailDao#retrieveCollectorDetailTableName()
*/
public String retrieveCollectorDetailTableName() {
ClassDescriptor classDescriptor = null;
DescriptorRepository globalRepository = descriptorRepository;
try {
classDescriptor = globalRepository.getDescriptorFor(CollectorDetail.class);
}
catch (ClassNotPersistenceCapableException e) {
throw new ClassNotPersistableException("class '" + CollectorDetail.class.getName() + "' is not persistable", e);
}
return classDescriptor.getFullTableName();
}
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:19,代码来源:CollectorDetailDaoOjb.java
示例7: retrieveObjectForEditOrCopy
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
@Override
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
Object dataObject = null;
try {
// Since the dataObject is a wrapper class we need to build it and populate with the agenda bo.
AgendaEditor agendaEditor = new AgendaEditor();
AgendaBo agenda = getLookupService().findObjectBySearch(((AgendaEditor) getDataObject()).getAgenda().getClass(), dataObjectKeys);
if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
String dateTimeStamp = (new Date()).getTime() + "";
String newAgendaName = AgendaItemBo.COPY_OF_TEXT + agenda.getName() + " " + dateTimeStamp;
AgendaBo copiedAgenda = agenda.copyAgenda(newAgendaName, dateTimeStamp);
document.getDocumentHeader().setDocumentDescription(NEW_AGENDA_EDITOR_DOCUMENT_TEXT);
document.setFieldsClearedOnCopy(true);
agendaEditor.setAgenda(copiedAgenda);
} else {
// set custom attributes map in AgendaEditor
// agendaEditor.setCustomAttributesMap(agenda.getAttributes());
agendaEditor.setAgenda(agenda);
}
agendaEditor.setCustomAttributesMap(agenda.getAttributes());
// set extra fields on AgendaEditor
agendaEditor.setNamespace(agenda.getContext().getNamespace());
agendaEditor.setContextName(agenda.getContext().getName());
dataObject = agendaEditor;
} catch (ClassNotPersistenceCapableException ex) {
if (!document.getOldMaintainableObject().isExternalBusinessObject()) {
throw new RuntimeException("Data Object Class: " + getDataObjectClass() +
" is not persistable and is not externalizable - configuration error");
}
// otherwise, let fall through
}
return dataObject;
}
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:41,代码来源:AgendaEditorMaintainable.java
示例8: checkForPrimaryKeys
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* OJB can handle only classes that declare at least one primary key attribute,
* this method checks this condition.
*
* @param realObject The real object to check
* @throws ClassNotPersistenceCapableException thrown if no primary key is specified for the objects class
*/
protected void checkForPrimaryKeys(final Object realObject) throws ClassNotPersistenceCapableException
{
// if no PKs are specified OJB can't handle this class !
if (m_pkValues == null || m_pkValues.length == 0)
{
throw createException("OJB needs at least one primary key attribute for class: ", realObject, null);
}
// arminw: should never happen
// if(m_pkValues[0] instanceof ValueContainer)
// throw new OJBRuntimeException("Can't handle pk values of type "+ValueContainer.class.getName());
}
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:Identity.java
示例9: getPlainDBObject
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* Retrieve an plain object (without populated references) by it's identity
* from the database
*
* @param cld the real {@link org.apache.ojb.broker.metadata.ClassDescriptor} of the object to refresh
* @param oid the {@link org.apache.ojb.broker.Identity} of the object
* @return A new plain object read from the database or <em>null</em> if not found
* @throws ClassNotPersistenceCapableException
*/
private Object getPlainDBObject(ClassDescriptor cld, Identity oid) throws ClassNotPersistenceCapableException
{
Object newObj = null;
// Class is NOT an Interface: it has a directly mapped table and we lookup this table first:
if (!cld.isInterface())
{
// 1. try to retrieve skalar fields from directly mapped table columns
newObj = dbAccess.materializeObject(cld, oid);
}
// if we did not find the object yet AND if the cld represents an Extent,
// we can lookup all tables of the extent classes:
if (newObj == null && cld.isExtent())
{
Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
while (extents.hasNext())
{
ClassDescriptor extCld = (ClassDescriptor) extents.next();
newObj = dbAccess.materializeObject(extCld, oid);
if (newObj != null)
{
break;
}
}
}
return newObj;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:40,代码来源:PersistenceBrokerImpl.java
示例10: getTopLevelClass
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* @see org.apache.ojb.broker.PersistenceBroker#getTopLevelClass
*/
public Class getTopLevelClass(Class clazz) throws PersistenceBrokerException
{
try
{
return descriptorRepository.getTopLevelClass(clazz);
}
catch (ClassNotPersistenceCapableException e)
{
throw new PersistenceBrokerException(e);
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:15,代码来源:PersistenceBrokerImpl.java
示例11: retrieveCollectorDetailTableName
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* Retrieves the DB table name that's mapped to instances of CollectorDetail by finding the class descriptor name from the
* class descriptor respository
* @return the table name where collector details are saved to
* @see org.kuali.kfs.gl.dataaccess.CollectorDetailDao#retrieveCollectorDetailTableName()
*/
public String retrieveCollectorDetailTableName() {
ClassDescriptor classDescriptor = null;
DescriptorRepository globalRepository = descriptorRepository;
try {
classDescriptor = globalRepository.getDescriptorFor(CollectorDetail.class);
}
catch (ClassNotPersistenceCapableException e) {
throw new ClassNotPersistableException("class '" + CollectorDetail.class.getName() + "' is not persistable", e);
}
return classDescriptor.getFullTableName();
}
开发者ID:kuali,项目名称:kfs,代码行数:19,代码来源:CollectorDetailDaoOjb.java
示例12: retrieveObjectForEditOrCopy
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
@Override
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
Object dataObject = null;
try {
// Since the dataObject is a wrapper class we need to build it and populate with the agenda bo.
AgendaEditor agendaEditor = new AgendaEditor();
AgendaBo agenda = findSingleMatching(getDataObjectService(),
((AgendaEditor) getDataObject()).getAgenda().getClass(), dataObjectKeys);
// HACK: force lazy loaded items to be fetched
forceLoadLazyRelations(agenda);
if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
String dateTimeStamp = (new Date()).getTime() + "";
String newAgendaName = AgendaItemBo.COPY_OF_TEXT + agenda.getName() + " " + dateTimeStamp;
AgendaBo copiedAgenda = agenda.copyAgenda(newAgendaName, dateTimeStamp);
document.getDocumentHeader().setDocumentDescription(NEW_AGENDA_EDITOR_DOCUMENT_TEXT);
document.setFieldsClearedOnCopy(true);
agendaEditor.setAgenda(copiedAgenda);
} else {
// set custom attributes map in AgendaEditor
// agendaEditor.setCustomAttributesMap(agenda.getAttributes());
agendaEditor.setAgenda(agenda);
}
agendaEditor.setCustomAttributesMap(agenda.getAttributes());
// set extra fields on AgendaEditor
agendaEditor.setNamespace(agenda.getContext().getNamespace());
agendaEditor.setContextName(agenda.getContext().getName());
dataObject = agendaEditor;
} catch (ClassNotPersistenceCapableException ex) {
if (!document.getOldMaintainableObject().isExternalBusinessObject()) {
throw new RuntimeException("Data Object Class: "
+ getDataObjectClass()
+ " is not persistable and is not externalizable - configuration error");
}
// otherwise, let fall through
}
return dataObject;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:46,代码来源:AgendaEditorMaintainable.java
示例13: buildNewObjectInstance
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* Builds a new instance for the class represented by the given class descriptor.
*
* @param cld The class descriptor
* @return The instance
*/
public static Object buildNewObjectInstance(ClassDescriptor cld)
{
Object result = null;
// If either the factory class and/or factory method is null,
// just follow the normal code path and create via constructor
if ((cld.getFactoryClass() == null) || (cld.getFactoryMethod() == null))
{
try
{
// 1. create an empty Object (persistent classes need a public default constructor)
Constructor con = cld.getZeroArgumentConstructor();
if(con == null)
{
throw new ClassNotPersistenceCapableException(
"A zero argument constructor was not provided! Class was '" + cld.getClassNameOfObject() + "'");
}
result = ConstructorHelper.instantiate(con);
}
catch (InstantiationException e)
{
throw new ClassNotPersistenceCapableException(
"Can't instantiate class '" + cld.getClassNameOfObject()+"'");
}
}
else
{
try
{
// 1. create an empty Object by calling the no-parms factory method
Method method = cld.getFactoryMethod();
if (Modifier.isStatic(method.getModifiers()))
{
// method is static so call it directly
result = method.invoke(null, null);
}
else
{
// method is not static, so create an object of the factory first
// note that this requires a public no-parameter (default) constructor
Object factoryInstance = cld.getFactoryClass().newInstance();
result = method.invoke(factoryInstance, null);
}
}
catch (Exception ex)
{
throw new PersistenceBrokerException("Unable to build object instance of class '"
+ cld.getClassNameOfObject() + "' from factory:" + cld.getFactoryClass()
+ "." + cld.getFactoryMethod(), ex);
}
}
return result;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:62,代码来源:ClassHelper.java
示例14: getDBObject
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
/**
* Retrieve an full materialized (dependent on the metadata settings)
* object by it's identity from the database, as well as caching the
* object
*
* @param oid The {@link org.apache.ojb.broker.Identity} of the object to for
* @return A new object read from the database or <em>null</em> if not found
* @throws ClassNotPersistenceCapableException
*/
private Object getDBObject(Identity oid) throws ClassNotPersistenceCapableException
{
Class c = oid.getObjectsRealClass();
if (c == null)
{
logger.info("Real class for used Identity object is 'null', use top-level class instead");
c = oid.getObjectsTopLevelClass();
}
ClassDescriptor cld = getClassDescriptor(c);
Object newObj = getPlainDBObject(cld, oid);
// loading references is useful only when the Object could be found in db:
if (newObj != null)
{
if (oid.getObjectsRealClass() == null)
{
oid.setObjectsRealClass(newObj.getClass());
}
/*
* synchronize on newObj so the ODMG-layer can take a snapshot only of
* fully cached (i.e. with all references + collections) objects
*/
synchronized (newObj)
{
objectCache.enableMaterializationCache();
try
{
// cache object immediately , so that references
// can be established from referenced Objects back to this Object
objectCache.doInternalCache(oid, newObj, ObjectCacheInternal.TYPE_NEW_MATERIALIZED);
/*
* Chris Lewington: can cause problems with multiple objects
* mapped to one table, as follows:
*
* if the class searched on does not match the retrieved
* class, eg a search on an OID retrieves a row but it could
* be a different class (OJB gets all column values),
* then trying to resolve references will fail as the object
* will not match the Class Descriptor.
*
* To be safe, get the descriptor of the retrieved object
* BEFORE resolving refs
*/
ClassDescriptor newObjCld = getClassDescriptor(newObj.getClass());
// don't force loading of references:
final boolean unforced = false;
// 2. retrieve non-skalar fields that contain objects retrievable from other tables
referencesBroker.retrieveReferences(newObj, newObjCld, unforced);
// 3. retrieve collection fields from foreign-key related tables:
referencesBroker.retrieveCollections(newObj, newObjCld, unforced);
objectCache.disableMaterializationCache();
}
catch(RuntimeException e)
{
objectCache.doLocalClear();
throw e;
}
}
}
return newObj;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:77,代码来源:PersistenceBrokerImpl.java
示例15: retrieveObjectForEditOrCopy
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; //导入依赖的package包/类
@Override
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
Object dataObject = null;
try {
// Since the dataObject is a wrapper class we need to build it and populate with the agenda bo.
AgendaEditor agendaEditor = new AgendaEditor();
AgendaBo agenda = getLookupService().findObjectBySearch(
((AgendaEditor) getDataObject()).getAgenda().getClass(), dataObjectKeys);
if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
String dateTimeStamp = (new Date()).getTime() + "";
String newAgendaName = AgendaItemBo.COPY_OF_TEXT + agenda.getName() + " " + dateTimeStamp;
AgendaBo copiedAgenda = agenda.copyAgenda(newAgendaName, dateTimeStamp);
document.getDocumentHeader().setDocumentDescription(NEW_AGENDA_EDITOR_DOCUMENT_TEXT);
document.setFieldsClearedOnCopy(true);
agendaEditor.setAgenda(copiedAgenda);
} else {
// set custom attributes map in AgendaEditor
// agendaEditor.setCustomAttributesMap(agenda.getAttributes());
agendaEditor.setAgenda(agenda);
}
agendaEditor.setCustomAttributesMap(agenda.getAttributes());
// set extra fields on AgendaEditor
agendaEditor.setNamespace(agenda.getContext().getNamespace());
agendaEditor.setContextName(agenda.getContext().getName());
dataObject = agendaEditor;
} catch (ClassNotPersistenceCapableException ex) {
if (!document.getOldMaintainableObject().isExternalBusinessObject()) {
throw new RuntimeException("Data Object Class: "
+ getDataObjectClass()
+ " is not persistable and is not externalizable - configuration error");
}
// otherwise, let fall through
}
return dataObject;
}
开发者ID:aapotts,项目名称:kuali_rice,代码行数:42,代码来源:AgendaEditorMaintainable.java
注:本文中的org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论