/** * INTERNAL: * Return the write lock field or the first primary key field if not using locking. */ protected DatabaseField getDoesExistField() { return this.descriptor.getPrimaryKeyFields().get(0); }
/** * ADVANCED: * Specify the primary key field of the descriptors table. * This should be called for each field that makes up the primary key of the table. * This can be used for advanced field types, such as XML nodes, or to set the field type. */ public void addPrimaryKeyField(DatabaseField field) { getPrimaryKeyFields().add(field); }
/** * INTERNAL: * Return true is the descriptor has primary key fields set. */ public boolean hasPrimaryKeyFields() { return m_descriptor.getPrimaryKeyFields().size() > 0; }
/** * PUBLIC: * Return the names of all the primary keys. */ public Vector<String> getPrimaryKeyFieldNames() { Vector<String> result = new Vector(getPrimaryKeyFields().size()); List primaryKeyFields = getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { result.addElement(((DatabaseField)primaryKeyFields.get(index)).getQualifiedName()); } return result; }
/** * INTERNAL: * Returns list of primary key fields from the reference descriptor. */ public List<DatabaseField> getTargetPrimaryKeyFields() { return getReferenceDescriptor().getPrimaryKeyFields(); }
protected void initializeIsUsedToSetPrimaryKey() { this.isUsedToSetPrimaryKey = false; if ((main[INSERT][MAPPED] == null) || main[INSERT][MAPPED].isEmpty()) { return; } List primaryKeys = getDescriptor().getPrimaryKeyFields(); for (int index = 0; (index < primaryKeys.size()) && !isUsedToSetPrimaryKey; index++) { this.isUsedToSetPrimaryKey = main[INSERT][MAPPED].contains(primaryKeys.get(index)); } }
/** * INTERNAL: * Returns list of primary key fields from the reference descriptor. */ public List<DatabaseField> getTargetPrimaryKeyFields() { return getReferenceDescriptor().getPrimaryKeyFields(); }
/** * INTERNAL: * If a user does not specify the target key then the primary keys of the target table are used. */ protected void initializeTargetKeysWithDefaults(AbstractSession session, ForeignReferenceMapping mapping) { List<DatabaseField> primaryKeyFields = mapping.getReferenceDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { getTargetKeyFields().addElement(primaryKeyFields.get(index)); } }
/** * 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: * If a user does not specify the target key then the primary keys of the target table are used. */ protected void initializeTargetKeysWithDefaults(AbstractSession session, ForeignReferenceMapping mapping) { List<DatabaseField> primaryKeyFields = mapping.getReferenceDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { getTargetKeyFields().addElement(primaryKeyFields.get(index)); } }
/** * Build the row from the primary key values. */ public AbstractRecord buildRowFromPrimaryKeyValues(Object key, AbstractSession session) { AbstractRecord databaseRow = createRecord(this.descriptor.getPrimaryKeyFields().size(), session); return writeIntoRowFromPrimaryKeyValues(databaseRow, key, session, true); }
@Override protected KeyElementAccessor[] initializePrimaryKeyFields(Class keyClass, AbstractSession session) { if (keyClass == null && getDescriptor().getPrimaryKeyFields().size() > 1) { KeyElementAccessor[] result = super.initializePrimaryKeyFields(keyClass, session); this.pkClass = Object[].class; return result; } else { return super.initializePrimaryKeyFields(keyClass, session); } }
public Vector extractPrimaryKeyFromObject(Object domainObject, AbstractSession session) { if (getDescriptor().hasInheritance() && (domainObject.getClass() != getDescriptor().getJavaClass()) && (!domainObject.getClass().getSuperclass().equals(getDescriptor().getJavaClass()))) { return session.getDescriptor(domainObject.getClass()).getObjectBuilder().extractPrimaryKeyFromObject(domainObject, session); } if (getDescriptor().getPrimaryKeyFields().size() == 0) { return null; } return super.extractPrimaryKeyFromObject(domainObject, session); }
@Override public Object extractPrimaryKeyFromObject(Object domainObject, AbstractSession session) { if (getDescriptor().hasInheritance() && (domainObject.getClass() != getDescriptor().getJavaClass()) && (!domainObject.getClass().getSuperclass().equals(getDescriptor().getJavaClass()))) { return session.getDescriptor(domainObject.getClass()).getObjectBuilder().extractPrimaryKeyFromObject(domainObject, session); } List<DatabaseField> descriptorPrimaryKeyFields = getDescriptor().getPrimaryKeyFields(); if (null == descriptorPrimaryKeyFields || descriptorPrimaryKeyFields.size() == 0) { return null; } return super.extractPrimaryKeyFromObject(domainObject, session); }
protected int objectChangedListOrderDuringUpdate(WriteObjectQuery query, CacheKey key, int newOrderValue) { AbstractRecord translationRow = (AbstractRecord)query.getTranslationRow().clone(); translationRow.put(this.listOrderField, newOrderValue); List pkValues = key.getKey(); List<DatabaseField> pkFields = getReferenceDescriptor().getPrimaryKeyFields(); int size = pkFields.size(); for(int i=0; i < size; i++) { translationRow.put(pkFields.get(i), pkValues.get(i)); } return (Integer)query.getSession().executeQuery(this.pkUpdateListOrderFieldQuery, translationRow); }
/** * INTERNAL: Generates the read all stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadAllStoredProcedure(ClassDescriptor descriptor) { ReadAllQuery readAllQuery = new ReadAllQuery(); readAllQuery.setDescriptor(descriptor); readAllQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readAllQuery, descriptor.getPrimaryKeyFields(), "RALL_"); }
/** * INTERNAL: Generates the read stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor) { ReadObjectQuery readQuery = new ReadObjectQuery(); readQuery.setDescriptor(descriptor); readQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readQuery, descriptor.getPrimaryKeyFields(), "READ_"); }
/** * INTERNAL: Generates the read stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor) { ReadObjectQuery readQuery = new ReadObjectQuery(); readQuery.setDescriptor(descriptor); readQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readQuery, descriptor.getPrimaryKeyFields(), "READ_"); }
/** * INTERNAL: Generates the delete stored procedure for this descriptor */ protected StoredProcedureDefinition generateDeleteStoredProcedure(ClassDescriptor descriptor) { DeleteObjectQuery deleteQuery = new DeleteObjectQuery(); deleteQuery.setDescriptor(descriptor); deleteQuery.setModifyRow(new DatabaseRecord()); return this.generateObjectStoredProcedure(deleteQuery, descriptor.getPrimaryKeyFields(), "DEL_"); }
/** * INTERNAL: Generates the read stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor) { ReadObjectQuery readQuery = new ReadObjectQuery(); readQuery.setDescriptor(descriptor); readQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readQuery, descriptor.getPrimaryKeyFields(), "READ_"); }