Package org.mongodb.morphia.entities

Examples of org.mongodb.morphia.entities.UniqueIndexOnValue


    @Test(expected = DuplicateKeyException.class)
    public void testUniqueIndexedEntity() throws Exception {
        getDs().ensureIndexes();
        assertThat(getDs().getCollection(UniqueIndexOnValue.class).getIndexInfo(), hasIndexNamed("l_ascending"));
        getDs().save(new UniqueIndexOnValue("a"));

        // this should throw...
        getDs().save(new UniqueIndexOnValue("v"));
    }
View Full Code Here


        // given
        getMorphia().map(UniqueIndexOnValue.class);
        getDs().ensureIndexes();
        final long value = 7L;

        final UniqueIndexOnValue entityWithUniqueName = new UniqueIndexOnValue();
        entityWithUniqueName.setValue(value);
        getDs().save(entityWithUniqueName);

        // when
        final UniqueIndexOnValue entityWithSameName = new UniqueIndexOnValue();
        entityWithSameName.setValue(value);
        getDs().save(entityWithSameName);
    }
View Full Code Here

TOP

Related Classes of org.mongodb.morphia.entities.UniqueIndexOnValue

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.