Package com.sleepycat.db

Examples of com.sleepycat.db.ForeignMultiKeyNullifier


        SecondaryKeyMetadata secKeyMeta =
            entityMeta.getSecondaryKeys().get(keyName);
        assertNotNull(secKeyMeta);

        /* Create key creator/nullifier. */
        ForeignMultiKeyNullifier keyNullifier = new PersistKeyCreator
            (catalog, entityMeta, keyCls.getName(), secKeyMeta);

        /* Convert entity to bytes. */
        PersistEntityBinding entityBinding =
            new PersistEntityBinding(catalog, entityCls.getName(), false);
        entityBinding.objectToData(entity, dataEntry);
        entityBinding.objectToKey(entity, keyEntry);

        /* Convert secondary key to bytes. */
        PersistKeyBinding keyBinding =
            new PersistKeyBinding(catalog, keyCls.getName(), false);
        DatabaseEntry secKeyEntry = new DatabaseEntry();
        if (keyValue != null) {
            keyBinding.objectToEntry(keyValue, secKeyEntry);
        }

        /* Nullify secondary key bytes within entity bytes. */
        boolean isKeyPresent = keyNullifier.nullifyForeignKey
            (null, keyEntry, dataEntry, secKeyEntry);
        assertEquals(keyValue != null, isKeyPresent);

        /* Convert modified entity bytes back to an entity. */
        Object entity2 = entityBinding.entryToObject(keyEntry, dataEntry);
View Full Code Here


        SecondaryKeyMetadata secKeyMeta =
            entityMeta.getSecondaryKeys().get(keyName);
        assertNotNull(secKeyMeta);

        /* Create key creator/nullifier. */
        ForeignMultiKeyNullifier keyNullifier = new PersistKeyCreator
            (catalog, entityMeta, keyCls.getName(), secKeyMeta);

        /* Convert entity to bytes. */
        PersistEntityBinding entityBinding =
            new PersistEntityBinding(catalog, entityCls.getName(), false);
        entityBinding.objectToData(entity, dataEntry);
        entityBinding.objectToKey(entity, keyEntry);

        /* Get secondary key binding. */
        PersistKeyBinding keyBinding =
            new PersistKeyBinding(catalog, keyCls.getName(), false);
        DatabaseEntry secKeyEntry = new DatabaseEntry();

        /* Nullify one key value at a time until all of them are gone. */
        while (true) {
            Object fieldObj = getField(entity, keyName);
            fieldObj = nullifyFirstElement(fieldObj, keyBinding, secKeyEntry);
            if (fieldObj == null) {
                break;
            }
            setField(entity, keyName, fieldObj);

            /* Nullify secondary key bytes within entity bytes. */
            boolean isKeyPresent = keyNullifier.nullifyForeignKey
                (null, keyEntry, dataEntry, secKeyEntry);
            assertEquals(keyValue != null, isKeyPresent);

            /* Convert modified entity bytes back to an entity. */
            Object entity2 = entityBinding.entryToObject(keyEntry, dataEntry);
View Full Code Here

TOP

Related Classes of com.sleepycat.db.ForeignMultiKeyNullifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.