本文整理汇总了Java中org.apache.ojb.broker.metadata.ClassDescriptor.getFieldDescriptions方法的典型用法代码示例。如果您正苦于以下问题:Java ClassDescriptor.getFieldDescriptions方法的具体用法?Java ClassDescriptor.getFieldDescriptions怎么用?Java ClassDescriptor.getFieldDescriptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ojb.broker.metadata.ClassDescriptor
的用法示例。
在下文中一共展示了ClassDescriptor.getFieldDescriptions方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrimaryKeyDescriptors
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private Collection<FieldDescriptor> getPrimaryKeyDescriptors(String clazz) {
final Collection<FieldDescriptor> pks = new ArrayList<FieldDescriptor>();
final ClassDescriptor cd = OjbUtil.findClassDescriptor(clazz, descriptorRepositories);
if (cd != null) {
//This causes a stackoverflow and appears to not work correctly
//return cd.getPkFields().length > 1;
int i = 0;
FieldDescriptor[] fds = cd.getFieldDescriptions();
if (fds != null) {
for (FieldDescriptor fd : fds) {
if (fd.isPrimaryKey()) {
pks.add(fd);
}
}
}
}
return pks;
}
示例2: refreshInstance
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* refresh all primitive typed attributes of a cached instance
* with the current values from the database.
* refreshing of reference and collection attributes is not done
* here.
* @param cachedInstance the cached instance to be refreshed
* @param oid the Identity of the cached instance
* @param cld the ClassDescriptor of cachedInstance
*/
private void refreshInstance(Object cachedInstance, Identity oid, ClassDescriptor cld)
{
// read in fresh copy from the db, but do not cache it
Object freshInstance = getPlainDBObject(cld, oid);
// update all primitive typed attributes
FieldDescriptor[] fields = cld.getFieldDescriptions();
FieldDescriptor fmd;
PersistentField fld;
for (int i = 0; i < fields.length; i++)
{
fmd = fields[i];
fld = fmd.getPersistentField();
fld.set(cachedInstance, fld.get(freshInstance));
}
}
示例3: testGenerateStandardTables
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
public void testGenerateStandardTables() {
StringBuffer buffer = new StringBuffer();
TableDescriptor tableDescriptor = new TableDescriptor();
this.torqueTableGenerator.generateStandardTable(tableDescriptor, buffer, "JUnit indx");
assertEquals(EMPTY_STANDARD_TABLE, buffer.toString());
buffer = new StringBuffer();
tableDescriptor.setName("PERSON_PROJECT");
ClassDescriptor classDescriptor = this.repository.getDescriptorFor(org.apache.ojb.odmg.shared.ProductGroup.class);
FieldDescriptor fieldDescriptors[] = classDescriptor.getFieldDescriptions();
for (int i = 0; i < fieldDescriptors.length; i++) {
tableDescriptor.addColumn(fieldDescriptors[i]);
}
tableDescriptor.setIndices(classDescriptor.getIndexes());
tableDescriptor.getReferences().addAll(classDescriptor.getObjectReferenceDescriptors());
this.torqueTableGenerator.generateStandardTable(tableDescriptor, buffer, "JUnit indx");
assertEquals(PERSON_PROJECT_TABLE, buffer.toString());
}
示例4: listFieldNames
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* @see org.kuali.rice.krad.service.PersistenceMetadataExplorerService#listFieldNames(java.lang.Class)
*/
@Override
public List listFieldNames(Class clazz) {
List fieldNames = new ArrayList();
ClassDescriptor classDescriptor = getClassDescriptor(clazz);
FieldDescriptor fieldDescriptors[] = classDescriptor.getFieldDescriptions();
for (int i = 0; i < fieldDescriptors.length; ++i) {
FieldDescriptor fieldDescriptor = fieldDescriptors[i];
fieldNames.add(fieldDescriptor.getAttributeName());
}
return fieldNames;
}
示例5: convertDBColumnNameToJavaName
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Returns the java attribute name corresponding to the column name
*
* @param classDescriptor the origin entry class
* @param columnName the DB column name
* @param caseInsensitive whether to do case insensitive matching
* @return the java attribute name
*/
protected String convertDBColumnNameToJavaName(ClassDescriptor classDescriptor, String columnName, boolean caseInsensitive) {
FieldDescriptor[] fields = classDescriptor.getFieldDescriptions();
for (FieldDescriptor field : fields) {
if (caseInsensitive && field.getColumnName().equalsIgnoreCase(columnName)) {
return field.getAttributeName();
}
if (!caseInsensitive && field.getColumnName().equals(columnName)) {
return field.getAttributeName();
}
}
return null;
}
示例6: extractAttributes
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private void extractAttributes(ClassDescriptor classDesc, Table mappedTable, Map columnsMap, Map requiredColumnsMap)
{
FieldDescriptor[] fieldDescs = classDesc.getFieldDescriptions();
if (fieldDescs != null)
{
for (int idx = 0; idx < fieldDescs.length; idx++)
{
Column column = mappedTable.findColumn(fieldDescs[idx].getColumnName());
if (column != null)
{
// we'll check whether another field (of not necessarily the same name)
// already maps to this column; if this is the case, we're ignoring
// this field
boolean alreadyMapped = false;
for (Iterator mappedColumnsIt = columnsMap.values().iterator(); mappedColumnsIt.hasNext();)
{
if (column.equals(mappedColumnsIt.next()))
{
alreadyMapped = true;
break;
}
}
if (!alreadyMapped)
{
String shortAttrName = getShortAttributeName(fieldDescs[idx].getAttributeName());
columnsMap.put(shortAttrName, column);
requiredColumnsMap.put(shortAttrName,
fieldDescs[idx].isPrimaryKey() ? Boolean.TRUE : Boolean.FALSE);
}
}
}
}
}
示例7: buildCriteria
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Build Criteria based on example object<br>
* all non null values are used as EqualToCriteria
*/
private static Criteria buildCriteria(Object anExample)
{
Criteria criteria = new Criteria();
ClassDescriptor cld = MetadataManager.getInstance().getRepository().getDescriptorFor(anExample.getClass());
FieldDescriptor[] fds = cld.getFieldDescriptions();
PersistentField f;
Object value;
for (int i = 0; i < fds.length; i++)
{
try
{
f = fds[i].getPersistentField();
value = f.get(anExample);
if (value != null)
{
criteria.addEqualTo(f.getName(), value);
}
}
catch (Throwable ex)
{
LoggerFactory.getDefaultLogger().error(ex);
}
}
return criteria;
}
示例8: buildFieldsForSelect
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Return the Fields to be selected.
*
* @param cld the ClassDescriptor
* @return the Fields to be selected
*/
protected FieldDescriptor[] buildFieldsForSelect(ClassDescriptor cld)
{
DescriptorRepository repository = cld.getRepository();
Set fields = new ListOrderedSet(); // keep the order of the fields
// add Standard Fields
// MBAIRD: if the object being queried on has multiple classes mapped to the table,
// then we will get all the fields that are a unique set across all those classes so if we need to
// we can materialize an extent
FieldDescriptor fds[] = repository.getFieldDescriptorsForMultiMappedTable(cld);
for (int i = 0; i < fds.length; i++)
{
fields.add(fds[i]);
}
// add inherited Fields. This is important when querying for a class having a super-reference
fds = cld.getFieldDescriptor(true);
for (int i = 0; i < fds.length; i++)
{
fields.add(fds[i]);
}
// add Fields of joined subclasses
Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, true);
for (int c = 0; c < multiJoinedClasses.length; c++)
{
ClassDescriptor subCld = repository.getDescriptorFor(multiJoinedClasses[c]);
fds = subCld.getFieldDescriptions();
for (int i = 0; i < fds.length; i++)
{
fields.add(fds[i]);
}
}
FieldDescriptor[] result = new FieldDescriptor[fields.size()];
fields.toArray(result);
return result;
}
示例9: appendSuperClassColumns
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private void appendSuperClassColumns(ClassDescriptor cldSuper, StringBuffer buf)
{
FieldDescriptor[] fields = cldSuper.getFieldDescriptions();
for (int i = 0; i < fields.length; i++)
{
FieldDescriptor field = fields[i];
if (i > 0)
{
buf.append(",");
}
buf.append(cldSuper.getFullTableName());
buf.append(".");
buf.append(field.getColumnName());
}
}
示例10: getDBFieldNamesForClass
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
*
* fetch the DB column names for the fields in the class for the query
* @param ojbClass = class of the query
* @return hash set of DB column names keyed by OJB attribute name,
*/
protected HashMap<String,String> getDBFieldNamesForClass(Class ojbClass)
{
ClassDescriptor ojbClassDescriptor = MetadataManager.getInstance().getRepository().getDescriptorFor(ojbClass);
FieldDescriptor[] fieldDescriptorArray = ojbClassDescriptor.getFieldDescriptions();
HashMap<String,String> returnSet = new HashMap<String,String>(((Double)(1.34*fieldDescriptorArray.length)).intValue());
for (FieldDescriptor fieldInDB: fieldDescriptorArray)
{
returnSet.put(fieldInDB.getAttributeName(),fieldInDB.getColumnName());
}
return returnSet;
}
示例11: handleDependentReferences
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Mark for creation all newly introduced dependent references.
* Mark for deletion all nullified dependent references.
* @return the list of created objects
*/
private ArrayList handleDependentReferences(Identity oid, Object userObject,
Object[] origFields, Object[] newFields, Object[] newRefs)
throws LockingException
{
ClassDescriptor mif = _pb.getClassDescriptor(userObject.getClass());
FieldDescriptor[] fieldDescs = mif.getFieldDescriptions();
Collection refDescs = mif.getObjectReferenceDescriptors();
int count = 1 + fieldDescs.length;
ArrayList newObjects = new ArrayList();
int countRefs = 0;
for (Iterator it = refDescs.iterator(); it.hasNext(); count++, countRefs++)
{
ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) it.next();
Identity origOid = (origFields == null ? null : (Identity) origFields[count]);
Identity newOid = (Identity) newFields[count];
if (rds.getOtmDependent())
{
if ((origOid == null) && (newOid != null))
{
ContextEntry entry = (ContextEntry) _objects.get(newOid);
if (entry == null)
{
Object relObj = newRefs[countRefs];
insertInternal(newOid, relObj, LockType.WRITE_LOCK,
true, oid, new Stack());
newObjects.add(newOid);
}
}
else if ((origOid != null) &&
((newOid == null) || !newOid.equals(origOid)))
{
markDelete(origOid, oid, false);
}
}
}
return newObjects;
}