public void createAttachment( GenKbAuthorization Authorization,
		GenKbAttachmentBuff Buff )
	{
		GenKbAttachmentPKey pkey = schema.getFactoryAttachment().newPKey();


		pkey.setRequiredAttachmentId( schema.nextAttachmentIdGen() );
		Buff.setRequiredAttachmentId( pkey.getRequiredAttachmentId() );

		GenKbAttachmentByContactIdxKey keyContactIdx = schema.getFactoryAttachment().newContactIdxKey();
		keyContactIdx.setRequiredContactId( Buff.getRequiredContactId() );

		GenKbAttachmentByUDescrIdxKey keyUDescrIdx = schema.getFactoryAttachment().newUDescrIdxKey();
		keyUDescrIdx.setRequiredContactId( Buff.getRequiredContactId() );
		keyUDescrIdx.setRequiredDescription( Buff.getRequiredDescription() );

		GenKbAttachmentByMimeTypeIdxKey keyMimeTypeIdx = schema.getFactoryAttachment().newMimeTypeIdxKey();
		keyMimeTypeIdx.setOptionalMimeTypeId( Buff.getOptionalMimeTypeId() );

		// Validate unique indexes

		if( dictByPKey.containsKey( pkey ) ) {
			throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException( getClass(), "createAttachment", pkey );
		}

		if( dictByUDescrIdx.containsKey( keyUDescrIdx ) ) {
			throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException( getClass(),
				"createAttachment",
				"AttachmentUDescrIdx",
				keyUDescrIdx );
		}

		// Validate foreign keys

		{
			boolean allNull = true;
			allNull = false;
			if( ! allNull ) {
				if( null == schema.getTableContact().readDerivedByPIdx( Authorization,
						Buff.getRequiredContactId() ) )
				{
					throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException( getClass(),
						"createAttachment",
						"Container",
						"Contact",
						"Contact",
						null );
				}
			}
		}

		{
			boolean allNull = true;
			if( Buff.getOptionalMimeTypeId() != null ) {
				allNull = false;
			}
			if( ! allNull ) {
				if( null == schema.getTableMimeType().readDerivedByPIdx( Authorization,
						Buff.getOptionalMimeTypeId() ) )
				{
					throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException( getClass(),
						"createAttachment",
						"Lookup",
						"MimeType",
						"MimeType",
						null );
				}
			}
		}

		// Proceed with adding the new record

		dictByPKey.put( pkey, Buff );

		SortedMap< GenKbAttachmentPKey, GenKbAttachmentBuff > subdictContactIdx;
		if( dictByContactIdx.containsKey( keyContactIdx ) ) {
			subdictContactIdx = dictByContactIdx.get( keyContactIdx );
		}
		else {
			subdictContactIdx = new TreeMap< GenKbAttachmentPKey, GenKbAttachmentBuff >();
			dictByContactIdx.put( keyContactIdx, subdictContactIdx );
		}
		subdictContactIdx.put( pkey, Buff );

		dictByUDescrIdx.put( keyUDescrIdx, Buff );

		SortedMap< GenKbAttachmentPKey, GenKbAttachmentBuff > subdictMimeTypeIdx;
		if( dictByMimeTypeIdx.containsKey( keyMimeTypeIdx ) ) {
			subdictMimeTypeIdx = dictByMimeTypeIdx.get( keyMimeTypeIdx );
		}
		else {
			subdictMimeTypeIdx = new TreeMap< GenKbAttachmentPKey, GenKbAttachmentBuff >();
			dictByMimeTypeIdx.put( keyMimeTypeIdx, subdictMimeTypeIdx );
		}
		subdictMimeTypeIdx.put( pkey, Buff );

	}