/** * INTERNAL: * Return any tables that will be required when this mapping is used as part of a join query */ public List<DatabaseTable> getAdditionalTablesForJoinQuery(){ List<DatabaseTable> tables = new ArrayList<DatabaseTable>(getReferenceDescriptor().getTables().size() + 1); tables.addAll(getReferenceDescriptor().getTables()); if (keyTableForMapKey != null){ tables.add(keyTableForMapKey); } return tables; }
/** * INTERNAL: * Return any tables that will be required when this mapping is used as part of a join query */ public List<DatabaseTable> getAdditionalTablesForJoinQuery(){ List<DatabaseTable> tables = new ArrayList<DatabaseTable>(getReferenceDescriptor().getTables().size() + 1); tables.addAll(getReferenceDescriptor().getTables()); if (keyTableForMapKey != null){ tables.add(keyTableForMapKey); } return tables; }
/** * INTERNAL: * Return any tables that will be required when this mapping is used as part of a join query * @return */ public List<DatabaseTable> getAdditionalTablesForJoinQuery(){ List<DatabaseTable> tables = new ArrayList<DatabaseTable>(getReferenceDescriptor().getTables().size() + 1); tables.addAll(getReferenceDescriptor().getTables()); if (keyTableForMapKey != null){ tables.add(keyTableForMapKey); } return tables; }
/** * INTERNAL: * Get all the fields for the map key */ public List<DatabaseField> getAllFieldsForMapKey(){ List<DatabaseField> fields = new ArrayList(getReferenceDescriptor().getAllFields().size() + getForeignKeyFields().size()); fields.addAll(getReferenceDescriptor().getAllFields()); fields.addAll(getForeignKeyFields()); return fields; }
/** * INTERNAL: * Get all the fields for the map key */ public List<DatabaseField> getAllFieldsForMapKey(){ List<DatabaseField> fields = new ArrayList(getReferenceDescriptor().getAllSelectionFields().size() + getForeignKeyFields().size()); fields.addAll(getReferenceDescriptor().getAllSelectionFields()); fields.addAll(getForeignKeyFields()); return fields; }
/** * INTERNAL: * Get all the fields for the map key */ public List<DatabaseField> getAllFieldsForMapKey(){ List<DatabaseField> fields = new ArrayList(getReferenceDescriptor().getAllSelectionFields().size() + getForeignKeyFields().size()); fields.addAll(getReferenceDescriptor().getAllSelectionFields()); fields.addAll(getForeignKeyFields()); return fields; }
/** * Return the descriptor for whichever side of the * relation has the "primary key". */ protected ClassDescriptor getPrimaryKeyDescriptor() { if (this.isForeignKeyRelationship()) { return this.getReferenceDescriptor(); } else { return this.getDescriptor(); } }
/** * Return the descriptor for whichever side of the * relation has the "primary key". */ protected ClassDescriptor getPrimaryKeyDescriptor() { if (this.isForeignKeyRelationship()) { return this.getReferenceDescriptor(); } else { return this.getDescriptor(); } }
/** * Return the descriptor for whichever side of the * relation has the "primary key". */ protected ClassDescriptor getPrimaryKeyDescriptor() { if (this.isForeignKeyRelationship()) { return this.getReferenceDescriptor(); } else { return this.getDescriptor(); } }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); for (int index = 0; index < getForeignKeyFields().size(); index++) { DatabaseField targetRelationField = getForeignKeyFields().elementAt(index); DatabaseField targetKey = getSourceToTargetKeyFields().get(targetRelationField); Object value = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, targetKey, session); keyFields.put(targetRelationField, value); } return keyFields; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); for (int index = 0; index < getForeignKeyFields().size(); index++) { DatabaseField targetRelationField = getForeignKeyFields().elementAt(index); DatabaseField targetKey = getSourceToTargetKeyFields().get(targetRelationField); Object value = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, targetKey, session); keyFields.put(targetRelationField, value); } return keyFields; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query * @return */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); for (int index = 0; index < getForeignKeyFields().size(); index++) { DatabaseField targetRelationField = getForeignKeyFields().elementAt(index); DatabaseField targetKey = getSourceToTargetKeyFields().get(targetRelationField); Object value = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, targetKey, session); keyFields.put(targetRelationField, value); } return keyFields; }
/** * INTERNAL: * Prepare a cascade locking policy. */ public void prepareCascadeLockingPolicy() { CascadeLockingPolicy policy = new CascadeLockingPolicy(getDescriptor(), getReferenceDescriptor()); policy.setQueryKeyFields(getSourceToTargetKeyFields(), ! isForeignKeyRelationship()); getReferenceDescriptor().addCascadeLockingPolicy(policy); }
/** * INTERNAL: * Prepare a cascade locking policy. */ @Override public void prepareCascadeLockingPolicy() { CascadeLockingPolicy policy = new CascadeLockingPolicy(getDescriptor(), getReferenceDescriptor()); policy.setQueryKeyFields(getSourceToTargetKeyFields(), ! isForeignKeyRelationship()); getReferenceDescriptor().addCascadeLockingPolicy(policy); }
/** * INTERNAL: * Prepare a cascade locking policy. */ @Override public void prepareCascadeLockingPolicy() { CascadeLockingPolicy policy = new CascadeLockingPolicy(getDescriptor(), getReferenceDescriptor()); policy.setQueryKeyFields(getSourceToTargetKeyFields(), ! isForeignKeyRelationship()); getReferenceDescriptor().addCascadeLockingPolicy(policy); }
/** * INTERNAL: * Return the classification for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ public Class getFieldClassification(DatabaseField fieldToClassify) throws DescriptorException { DatabaseField fieldInTarget = getSourceToTargetKeyFields().get(fieldToClassify); if (fieldInTarget == null) { return null;// Can be registered as multiple table secondary field mapping } DatabaseMapping mapping = getReferenceDescriptor().getObjectBuilder().getMappingForField(fieldInTarget); if (mapping == null) { return null;// Means that the mapping is read-only } return mapping.getFieldClassification(fieldInTarget); }
/** * INTERNAL: * Return the classification for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ @Override public Class getFieldClassification(DatabaseField fieldToClassify) throws DescriptorException { DatabaseField fieldInTarget = getSourceToTargetKeyFields().get(fieldToClassify); if (fieldInTarget == null) { return null;// Can be registered as multiple table secondary field mapping } DatabaseMapping mapping = getReferenceDescriptor().getObjectBuilder().getMappingForField(fieldInTarget); if (mapping == null) { return null;// Means that the mapping is read-only } return mapping.getFieldClassification(fieldInTarget); }
/** * INTERNAL: * Create a query key that links to the map key * @return */ public QueryKey createQueryKeyForMapKey(){ OneToOneQueryKey key = new OneToOneQueryKey(); key.setDescriptor(getReferenceDescriptor()); key.setReferenceClass(getReferenceClass()); key.setJoinCriteria(getAdditionalSelectionCriteriaForMapKey()); return key; }
/** * INTERNAL: * Create a query key that links to the map key * @return */ public QueryKey createQueryKeyForMapKey(){ OneToOneQueryKey key = new OneToOneQueryKey(); key.setDescriptor(getReferenceDescriptor()); key.setReferenceClass(getReferenceClass()); key.setJoinCriteria(getAdditionalSelectionCriteriaForMapKey()); return key; }
/** * INTERNAL: * Create a query key that links to the map key * @return */ public QueryKey createQueryKeyForMapKey(){ OneToOneQueryKey key = new OneToOneQueryKey(); key.setDescriptor(getReferenceDescriptor()); key.setReferenceClass(getReferenceClass()); key.setJoinCriteria(getAdditionalSelectionCriteriaForMapKey()); return key; }