/** * INTERNAL: * Add the field-value pair to the row. */ public Object put(DatabaseField key, Object value) { checkValues(); this.fieldsArray = null; this.valuesArray = null; return super.put(key, value); }
/** * INTERNAL: * Add the field-value pair to the row. */ public Object put(DatabaseField key, Object value) { checkValues(); this.fieldsArray = null; this.valuesArray = null; return super.put(key, value); }
/** * INTERNAL: * This method is used to store the FK values used for this mapping in the cachekey. * This is used when the mapping is protected but we have retrieved the fk values and will cache * them for use when the entity is cloned. */ public void cacheForeignKeyValues(AbstractRecord databaseRecord, CacheKey cacheKey, AbstractSession session) { Set<DatabaseField> foreignKeys = this.descriptor.getForeignKeyValuesForCaching(); if (foreignKeys.isEmpty()) { return; } DatabaseRecord cacheRecord = new DatabaseRecord(foreignKeys.size()); for (DatabaseField field : foreignKeys) { cacheRecord.put(field, databaseRecord.get(field)); } cacheKey.setProtectedForeignKeys(cacheRecord); }
/** * INTERNAL: * This method is used to store the FK values used for this mapping in the cachekey. * This is used when the mapping is protected but we have retrieved the fk values and will cache * them for use when the entity is cloned. */ public void cacheForeignKeyValues(Object source, CacheKey cacheKey, ClassDescriptor descriptor, AbstractSession session) { Set<DatabaseField> foreignKeys = this.descriptor.getForeignKeyValuesForCaching(); if (foreignKeys.isEmpty()) { return; } DatabaseRecord cacheRecord = new DatabaseRecord(foreignKeys.size()); for (DatabaseField field : foreignKeys) { cacheRecord.put(field, extractValueFromObjectForField(source, field, session)); } cacheKey.setProtectedForeignKeys(cacheRecord); }
/** * INTERNAL: * This method is used to store the FK values used for this mapping in the cachekey. * This is used when the mapping is protected but we have retrieved the fk values and will cache * them for use when the entity is cloned. */ public void cacheForeignKeyValues(AbstractRecord databaseRecord, CacheKey cacheKey, AbstractSession session) { Set<DatabaseField> foreignKeys = this.descriptor.getForeignKeyValuesForCaching(); if (foreignKeys.isEmpty()) { return; } DatabaseRecord cacheRecord = new DatabaseRecord(foreignKeys.size()); for (DatabaseField field : foreignKeys) { cacheRecord.put(field, databaseRecord.get(field)); } cacheKey.setProtectedForeignKeys(cacheRecord); }
/** * INTERNAL: * This method is used to store the FK values used for this mapping in the cachekey. * This is used when the mapping is protected but we have retrieved the fk values and will cache * them for use when the entity is cloned. */ public void cacheForeignKeyValues(Object source, CacheKey cacheKey, ClassDescriptor descriptor, AbstractSession session) { Set<DatabaseField> foreignKeys = this.descriptor.getForeignKeyValuesForCaching(); if (foreignKeys.isEmpty()) { return; } DatabaseRecord cacheRecord = new DatabaseRecord(foreignKeys.size()); for (DatabaseField field : foreignKeys) { cacheRecord.put(field, extractValueFromObjectForField(source, field, session)); } cacheKey.setProtectedForeignKeys(cacheRecord); }
extraData.put(this.listOrderField, iCurrent);
extraData.put(this.listOrderField, iCurrent);
extraData.put(this.listOrderField, iCurrent);
/** * INTERNAL: * This method is for processing all FieldResults for a mapping. Adds DatabaseFields to the passed in entityRecord */ public void getValueFromRecordForMapping(DatabaseRecord entityRecord,DatabaseMapping mapping, FieldResult fieldResult, DatabaseRecord databaseRecord){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); /** check if this FieldResult contains any other FieldResults, process it if it doesn't */ if (fieldResult.getFieldResults()==null){ DatabaseField dbfield = processValueFromRecordForMapping(currentDescriptor,fieldResult.getMultipleFieldIdentifiers(),1); /** If it is a 1:1 mapping we need to do the target to source field conversion. If it is an aggregate, it is fine as it is*/ if (mapping.isOneToOneMapping()){ dbfield = (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(dbfield)); } entityRecord.put(dbfield, databaseRecord.get(fieldResult.getColumn())); return; } /** This processes each FieldResult stored in the collection of FieldResults individually */ Iterator fieldResults = fieldResult.getFieldResults().iterator(); while (fieldResults.hasNext()){ FieldResult tempFieldResult = ((FieldResult)fieldResults.next()); DatabaseField dbfield = processValueFromRecordForMapping(currentDescriptor,tempFieldResult.getMultipleFieldIdentifiers(),1); if (mapping.isOneToOneMapping()){ dbfield = (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(dbfield)); } entityRecord.put(dbfield, databaseRecord.get(tempFieldResult.getColumn())); } }
/** * INTERNAL: * This method is for processing all FieldResults for a mapping. Adds DatabaseFields to the passed in entityRecord */ public void getValueFromRecordForMapping(DatabaseRecord entityRecord,DatabaseMapping mapping, FieldResult fieldResult, DatabaseRecord databaseRecord){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); /** check if this FieldResult contains any other FieldResults, process it if it doesn't */ if (fieldResult.getFieldResults()==null){ DatabaseField dbfield = processValueFromRecordForMapping(currentDescriptor,fieldResult.getMultipleFieldIdentifiers(),1); /** If it is a 1:1 mapping we need to do the target to source field conversion. If it is an aggregate, it is fine as it is*/ if (mapping.isOneToOneMapping()){ dbfield = (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(dbfield)); } entityRecord.put(dbfield, databaseRecord.get(fieldResult.getColumnName())); return; } /** This processes each FieldResult stored in the collection of FieldResults individually */ Iterator fieldResults = fieldResult.getFieldResults().iterator(); while (fieldResults.hasNext()){ FieldResult tempFieldResult = ((FieldResult)fieldResults.next()); DatabaseField dbfield = processValueFromRecordForMapping(currentDescriptor,tempFieldResult.getMultipleFieldIdentifiers(),1); if (mapping.isOneToOneMapping()){ dbfield = (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(dbfield)); } entityRecord.put(dbfield, databaseRecord.get(tempFieldResult.getColumnName())); } }
/** * INTERNAL: * This method is for processing all FieldResults for a mapping. Adds DatabaseFields to the passed in entityRecord */ public void getValueFromRecordForMapping(DatabaseRecord entityRecord,DatabaseMapping mapping, FieldResult fieldResult, DatabaseRecord databaseRecord){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); /** check if this FieldResult contains any other FieldResults, process it if it doesn't */ if (fieldResult.getFieldResults()==null){ DatabaseField dbfield = processValueFromRecordForMapping(currentDescriptor,fieldResult.getMultipleFieldIdentifiers(),1); /** If it is a 1:1 mapping we need to do the target to source field conversion. If it is an aggregate, it is fine as it is*/ if (mapping.isOneToOneMapping()){ dbfield = (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(dbfield)); } entityRecord.put(dbfield, databaseRecord.get(fieldResult.getColumn())); return; } /** This processes each FieldResult stored in the collection of FieldResults individually */ Iterator fieldResults = fieldResult.getFieldResults().iterator(); while (fieldResults.hasNext()){ FieldResult tempFieldResult = ((FieldResult)fieldResults.next()); DatabaseField dbfield = processValueFromRecordForMapping(currentDescriptor,tempFieldResult.getMultipleFieldIdentifiers(),1); if (mapping.isOneToOneMapping()){ dbfield = (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(dbfield)); } entityRecord.put(dbfield, databaseRecord.get(tempFieldResult.getColumn())); } }
entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), value); if (fieldResult != null){ if (mapping.getFields().size() == 1 ) { entityRecord.put(mapping.getFields().firstElement(), record.get(fieldResult.getColumn())); } else if (mapping.getFields().size() >1){ getValueFromRecordForMapping(entityRecord,mapping,fieldResult,record); for (Iterator fields = mapping.getFields().iterator(); fields.hasNext();) { DatabaseField field = (DatabaseField)fields.next(); entityRecord.put(field, record.get(field));
throw QueryException.discriminatorColumnNotSelected(this.discriminatorColumn, query.getSQLResultSetMapping().getName()); entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), record.get(this.discriminatorColumn)); } else { entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), record.get(descriptor.getInheritancePolicy().getClassIndicatorField())); if (fieldResult != null){ if (mapping.getFields().size() == 1 ) { entityRecord.put(mapping.getFields().firstElement(), record.get(fieldResult.getColumnName())); } else if (mapping.getFields().size() >1){ getValueFromRecordForMapping(entityRecord,mapping,fieldResult,record); for (Iterator fields = mapping.getFields().iterator(); fields.hasNext();) { DatabaseField field = (DatabaseField)fields.next(); entityRecord.put(field, record.get(field));
entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), value); if (fieldResult != null){ if (mapping.getFields().size() == 1 ) { entityRecord.put(mapping.getFields().firstElement(), record.get(fieldResult.getColumn())); } else if (mapping.getFields().size() >1){ getValueFromRecordForMapping(entityRecord,mapping,fieldResult,record); for (Iterator fields = mapping.getFields().iterator(); fields.hasNext();) { DatabaseField field = (DatabaseField)fields.next(); entityRecord.put(field, record.get(field));
DatabaseRecord nested = new DatabaseRecord(); if (relation.getOperator().getSelector() == ExpressionOperator.GreaterThan) { nested.put("$gt", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.LessThan) { nested.put("$lt", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.LessThanEqual) { nested.put("$lte", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.GreaterThanEqual) { nested.put("$gte", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.NotEqual) { nested.put("$ne", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.In) { nested.put("$in", right); row.put(left, nested); } else if (relation.getOperator().getSelector() == ExpressionOperator.NotIn) { nested.put("$nin", right); row.put(left, nested); } else { pattern = Helper.convertLikeToRegex(pattern); nested.put("$regex", pattern); row.put(left, nested); } else if (function.getOperator().getSelector() == ExpressionOperator.Not) { nested.put("$ne", right); } else { nested.put("not", right);
appendExpressionToSortRow(orderBy, sort, query); row.put(MongoRecord.SORT, sort); for (Object field : ((SQLSelectStatement)statement).getFields()) { if (field instanceof DatabaseField) { select.put((DatabaseField)field, 1); } else if (field instanceof Expression) { Object value = extractValueFromExpression((Expression)field, readQuery); throw new EISException("Query too complex for Mongo translation, only field selects are supported in query: " + query); select.put((DatabaseField)value, 1); row.put("$select", select);