}
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);
// Check if this is the auto-added field for unknown pk
// 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));
}
// Check if this is the auto-added field for 2 way managed rels
// support. If so, return a private field of type according to
// cardinality of the relationship.
else 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));
}
}
// Check if this is the auto-added version field.
// If so, return a private field of type long.
else if (ejbFieldName.startsWith(
NameMapper.GENERATED_VERSION_FIELD_PREFIX) &&
nameMapper.isGeneratedField(ejbName, ejbFieldName))
{
returnObject = new MemberWrapper(ejbFieldName,
Long.TYPE, Modifier.PRIVATE,
(Class)getClass(className));
}