/** * INTERNAL: */ protected void prepareOneToOneSelectionQuery(OneToOneMapping sourceMapping, AbstractSession session) { // Clone the mapping because in reality that is what we have, that // is, a 1-1 mapping to each class of the hierarchy. OneToOneMapping oneToOne = (OneToOneMapping) sourceMapping.clone(); // Update the target keys to have an empty table (descriptor will figure it out) for (DatabaseField targetField : oneToOne.getTargetToSourceKeyFields().keySet()) { targetField.setTable(new DatabaseTable()); } addSelectionQuery(oneToOne, sourceMapping, session); }
/** * INTERNAL: */ protected void prepareOneToManySelectionQuery(OneToManyMapping sourceMapping, AbstractSession session) { // Clone the mapping because in reality that is what we have, that // is, a 1-M mapping to each class of the hierarchy. OneToManyMapping oneToMany = (OneToManyMapping) sourceMapping.clone(); // Update the foreign key fields on the mapping. Basically, take the // table name off and let the descriptor figure it out. Vector<DatabaseField> targetForeignKeyFields = new Vector<DatabaseField>(); for (DatabaseField fkField : oneToMany.getTargetForeignKeysToSourceKeys().keySet()) { targetForeignKeyFields.add(new DatabaseField(fkField.getName())); } // Update our foreign key fields and clear the key maps. oneToMany.setTargetForeignKeyFields(targetForeignKeyFields); oneToMany.getTargetForeignKeysToSourceKeys().clear(); oneToMany.getSourceKeysToTargetForeignKeys().clear(); addSelectionQuery(oneToMany, sourceMapping, session); }
/** * INTERNAL: */ protected void prepareManyToManySelectionQuery(ManyToManyMapping sourceMapping, AbstractSession session) { // Clone the mapping because in reality that is what we have, that // is, a M-M mapping to each class of the hierarchy. ManyToManyMapping manyToMany = (ManyToManyMapping) sourceMapping.clone(); // Update the foreign key fields on the mapping. Basically, take the // table name off and let the descriptor figure it out. for (DatabaseField keyField : manyToMany.getTargetKeyFields()) { keyField.setTable(new DatabaseTable()); } addSelectionQuery(manyToMany, sourceMapping, session); }