Refine search
@SuppressWarnings("unchecked") @Override public void initialize(final DatabaseMapping mapping, final Session session) { enumClass = mapping.getAttributeClassification(); pgTypeName = mapping.getField().getColumnDefinition(); checkPgTypeName(); // if (Strings.isNullOrEmpty(pgTypeName)) { // pgTypeName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, enumClass.getSimpleName()); // } }
static EntityFieldInspector<? extends Annotation> getFieldInspector(final DatabaseMapping databaseMapping) { final String attributeName = databaseMapping.getAttributeName(); final Class<?> entityClass = databaseMapping.getDescriptor().getJavaClass(); Set<Field> fieldsWithName = ReflectionUtils.getAllFields(entityClass, ReflectionUtils.withName(attributeName)); final Field field = Iterables.get(fieldsWithName, 0); // final Field field = ReflectionUtils.findField(entityClass, // attributeName); return new ColumnFieldInspector(field); }
/** * INTERNAL: * This method is used to store the FK fields that can be cached that correspond to noncacheable mappings * the FK field values will be used to re-issue the query when cloning the shared cache entity */ @Override public void collectQueryParameters(Set<DatabaseField> record){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()){ if ((mapping.isForeignReferenceMapping() && !mapping.isCacheable()) || (mapping.isAggregateObjectMapping() && mapping.getReferenceDescriptor().hasNoncacheableMappings())){ ((ForeignReferenceMapping) mapping).collectQueryParameters(record); } } }
ClassDescriptor descriptor = nodeValue.getMapping().getReferenceDescriptor(); descriptor = nodeValue.getMapping().getDescriptor(); TreeObjectBuilder objectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder(); final XPathNodeWrapper nodeWrapper = actualNodeWrapper;
/** * PUBLIC: * Add a database mapping to the receiver. Perform any required * initialization of both the mapping and the receiving descriptor * as a result of adding the new mapping. */ public DatabaseMapping addMapping(DatabaseMapping mapping) { // For CR#2646, if the mapping already points to the parent descriptor then leave it. if (mapping.getDescriptor() == null) { mapping.setDescriptor(this); } getMappings().add(mapping); return mapping; }
/** * PUBLIC: * Add a database mapping to the receiver. Perform any required * initialization of both the mapping and the receiving descriptor * as a result of adding the new mapping. */ public DatabaseMapping addMapping(DatabaseMapping mapping) { // For CR#2646, if the mapping already points to the parent descriptor then leave it. if (mapping.getDescriptor() == null) { mapping.setDescriptor(this); } getMappings().addElement(mapping); return mapping; }
/** * INTERNAL: * Return all the fields */ public Vector getFields() { if (isAttribute()) { Vector result = new Vector(1); DatabaseField field = getField(); if (field != null) { result.addElement(field); } return result; } else { Vector result = new Vector(); result.addAll(super.getFields()); if (mapping.isCollectionMapping()){ List<DatabaseField> fields = mapping.getContainerPolicy().getAllFieldsForMapKey((CollectionMapping)mapping); if (fields != null){ result.addAll(fields); } } return result; } }
/** * INTERNAL: * If a user does not specify the source key then the primary keys of the source table are used. */ protected void initializeSourceKeysWithDefaults(AbstractSession session, DatabaseMapping mapping) { List<DatabaseField> primaryKeyFields = mapping.getDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { getSourceKeyFields().addElement(primaryKeyFields.get(index)); } }
/** * INTERNAL: */ @Override public DatabaseField getField() { if (!isAttribute()) { return null; } QueryKey key = getQueryKeyOrNull(); if ((key != null) && key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } DatabaseMapping mapping = getMapping(); if ((mapping == null) || mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); }
/** * Return the field used for the query key name. */ public DatabaseField getFieldForQueryKeyName(String name) { QueryKey key = this.descriptor.getQueryKeyNamed(name); if (key == null) { DatabaseMapping mapping = getMappingForAttributeName(name); if (mapping == null) { return null; } if (mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); } if (key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } return null; }
@Override public Class<?> getPropertyType(int propertyIndex) { return getDescriptor().getMappings().get(propertyIndex).getAttributeClassification(); }
public NestedTable(QueryKeyExpression queryKeyExpression) { super(); this.queryKeyExpression = queryKeyExpression; setName((queryKeyExpression.getMapping().getDescriptor().getTables().firstElement()).getName()); tableQualifier = (queryKeyExpression.getMapping().getDescriptor().getTables().firstElement()).getQualifiedName(); }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return mapping.getFields().firstElement(); } }
/** * INTERNAL: * Allow for initialization of properties and validation. */ public void preInitialize(AbstractSession session) throws DescriptorException { try { getAttributeAccessor().initializeAttributes(getDescriptor().getJavaClass()); } catch (DescriptorException exception) { exception.setMapping(this); session.getIntegrityChecker().handleError(exception); } }
/** * Append list of columns from descriptor class to provided {@link StringBuilder}. * Use to create content of columns brackets in <code>INSERT INTO table (col1, col1) VALUES ...</code>. * @param target Target {@link StringBuilder}. * @param mappings Object attributes mappings. * @param separator String to separate values in list. */ public static void buildColsFromMappings(final StringBuilder target, final Collection<DatabaseMapping> mappings, final String separator) { for (Iterator<DatabaseMapping> i = mappings.iterator(); i.hasNext(); ) { target.append(i.next().getField().getName()); if (i.hasNext()) { target.append(separator); } } }
public List<String> getPropertyNames() { List<String> propertyNames = new ArrayList<String>(); if (type != null && type.getDescriptor() != null) { for (DatabaseMapping dm : type.getDescriptor().getMappings()) { propertyNames.add(dm.getAttributeName()); } } return propertyNames; }
public static DescriptorException mustBeReadOnlyMappingWhenStoredInCache(DatabaseMapping mapping) { Object[] args = { mapping.getDescriptor().getJavaClass() }; DescriptorException descriptorException = new DescriptorException(ExceptionMessageGenerator.buildMessage(DescriptorException.class, LOCK_MAPPING_MUST_BE_READONLY, args), mapping); descriptorException.setErrorCode(LOCK_MAPPING_MUST_BE_READONLY); return descriptorException; }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the insert query is being initialized to ensure the fields for the map key are in the insert query */ @Override public void addFieldsForMapKey(AbstractRecord joinRow){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()) { if (!mapping.isReadOnly()) { for (DatabaseField field : mapping.getFields()) { if (field.isUpdatable()){ joinRow.put(field, null); } } } } }
/** * Return whether the given attribute is joined as a result of a join on a mapping */ protected boolean isAttributeMappingJoined(DatabaseMapping attributeMapping) { return isAttributeNameInJoinedExpressionList(attributeMapping.getAttributeName(), getJoinedMappingExpressions()); }
/** * INTERNAL: * Add the key and value from provided association to the deleted objects list on the commit manager. */ @Override public void recordPrivateOwnedRemovals(Object object,ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow){ if (((DatabaseMapping)keyMapping).isPrivateOwned()){ Object key = ((Map.Entry)object).getKey(); ((DatabaseMapping)keyMapping).getReferenceDescriptor().getObjectBuilder().recordPrivateOwnedRemovals(key, uow, false); } super.recordPrivateOwnedRemovals(((Map.Entry)object).getValue(), referenceDescriptor, uow); }