use of com.sun.jdo.api.persistence.model.jdo.RelationshipElement in project Payara by payara.
the class DeploymentDescriptorModel method updateFieldWrapper.
private MemberWrapper updateFieldWrapper(MemberWrapper returnObject, String className, String fieldName) {
NameMapper nameMapper = getNameMapper();
if (returnObject == null) {
// can't call isPersistent or isKey because that calls
// hasField which calls getField and that would end up
// in an endless loop
PersistenceFieldElement field = getPersistenceFieldInternal(className, fieldName);
if (field != null) {
String ejbName = getEjbName(className);
String ejbFieldName = nameMapper.getEjbFieldForPersistenceField(className, fieldName);
// support. If so, return a private field of type Long.
if (field.isKey() && (ejbName != null) && (nameMapper.getKeyClassTypeForEjbName(ejbName) == NameMapper.UNKNOWN_KEY_CLASS)) {
returnObject = new MemberWrapper(ejbFieldName, Long.class, Modifier.PRIVATE, (Class) getClass(className));
} else // cardinality of the relationship.
if ((field instanceof RelationshipElement) && nameMapper.isGeneratedEjbRelationship(ejbName, ejbFieldName)) {
RelationshipElement rel = (RelationshipElement) field;
Class classType = null;
// figure out the type
if (rel.getUpperBound() > 1)
classType = java.util.HashSet.class;
else {
String[] inverse = nameMapper.getEjbFieldForGeneratedField(ejbName, ejbFieldName);
classType = (Class) getClass(inverse[0]);
}
if (classType != null) {
returnObject = new MemberWrapper(ejbFieldName, classType, Modifier.PRIVATE, (Class) getClass(className));
}
} else // If so, return a private field of type long.
if (ejbFieldName.startsWith(NameMapper.GENERATED_VERSION_FIELD_PREFIX) && nameMapper.isGeneratedField(ejbName, ejbFieldName)) {
returnObject = new MemberWrapper(ejbFieldName, Long.TYPE, Modifier.PRIVATE, (Class) getClass(className));
}
}
}
// non-primitive, non-wrapper type, convert it to byte[] here
if (!isPersistentTypeAllowed(getType(returnObject), getClassLoader()) && isSerializable(returnObject)) {
returnObject.setType(byte[].class);
}
return returnObject;
}
use of com.sun.jdo.api.persistence.model.jdo.RelationshipElement in project Payara by payara.
the class ClassDesc method initializeFields.
/**
* This method maps all the visible fields. It has the side-effect of computing
* the value for maxVisibleFields.
*/
private void initializeFields() {
ArrayList concurrencyGroups = new ArrayList();
persistentFields = pcElement.getFields();
for (int i = 0; i < persistentFields.length; i++) {
PersistenceFieldElement pcf = persistentFields[i];
MappingFieldElementImpl mdf = (MappingFieldElementImpl) mdConfig.getField(pcf.getName());
if (mdf == null) {
throw new JDOFatalUserException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.fieldnotmapped", pcf.getName(), pcElement.getName()));
}
FieldDesc f;
if (!(mdf instanceof MappingRelationshipElement)) {
f = createLocalField(mdf);
} else {
f = createForeignField((RelationshipElement) pcf, (MappingRelationshipElementImpl) mdf);
}
initializeFetchAndConcurrencyGroup(f, pcf, mdf, concurrencyGroups);
if (mdf.isReadOnly()) {
f.sqlProperties |= FieldDesc.PROP_READ_ONLY;
}
try {
f.setupDesc(pcClass, pcf.getName());
} catch (JDOException e) {
throw e;
} catch (Exception e) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.loadfailed.field", pcf.getName(), pcElement.getName()), e);
}
f.absoluteID = pcf.getFieldNumber();
addField(f);
if (logger.isLoggable(Logger.FINEST)) {
Object[] items = new Object[] { f.getName(), new Integer(f.absoluteID) };
// NOI18N
logger.finest("sqlstore.model.classdesc.fieldinfo", items);
}
}
this.maxVisibleFields = fields.size();
}
use of com.sun.jdo.api.persistence.model.jdo.RelationshipElement in project Payara by payara.
the class JDOMetaDataModelImpl method isDefaultFetchGroupField.
/**
* Tests whether a field of a class is known to be part of the
* Default Fetch Group. Please note that for a relationship field, this
* method always returns false.
*/
public boolean isDefaultFetchGroupField(String classPath, String fieldName) throws JDOMetaDataUserException, JDOMetaDataFatalError {
final String className = pathToName(classPath);
boolean isdfgField = model.isDefaultFetchGroup(className, fieldName);
if (isdfgField) {
final PersistenceFieldElement pfe = model.getPersistenceField(className, fieldName);
if (pfe instanceof RelationshipElement) {
// This is a relationship field. Flag it as not belonging
// to dfg.
// Relationship fields are always flaged as not belonging to dfg
// This assures that access to a relationship fields is always
// mediated.
// Please see call to this method from following for more details.
// 1. EJBMetaDataModelImpl#getFieldFlags()
// 2. MethodAnnotater#notePutFieldAnnotation()
// 3. MethodAnnotater#noteGetFieldAnnotation()
isdfgField = false;
}
}
return isdfgField;
}
Aggregations