当前位置: 首页>>代码示例>>Java>>正文


Java Entity类代码示例

本文整理汇总了Java中org.mongodb.morphia.annotations.Entity的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Entity类属于org.mongodb.morphia.annotations包,在下文中一共展示了Entity类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: datastore

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
@Bean
public Datastore datastore(Morphia morphia) throws ClassNotFoundException, IOException {

    List<String> packageNamesFromApplication = MorphiaUtils.getApplicationPackageName(applicationContext);

    Set<Class<?>> classes = packageNamesFromApplication
            .parallelStream()
            .flatMap(packageName -> MorphiaUtils.getClasses(packageName).parallelStream())
            .collect(Collectors.toSet());

    classes.parallelStream()
            .filter(clazz -> Objects.nonNull(clazz.getAnnotation(Entity.class)))
            .forEach( clazz ->morphia.map(clazz));

    Datastore dataStore = morphia.createDatastore(mongoClient, mongoTemplate.getDb().getName());
    dataStore.ensureIndexes();
    return dataStore;
}
 
开发者ID:ganchix,项目名称:morphia-spring-boot-starter,代码行数:19,代码来源:MorphiaAutoConfiguration.java

示例2: createConfiguration

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
    Class entities = QueryEntities.class;
    Class entity = Entity.class;
    Class superType = QuerySupertype.class;
    Class embedded = Embedded.class;
    Class skip = Transient.class;
    DefaultConfiguration conf = new DefaultConfiguration(roundEnv, this.processingEnv.getOptions(), Collections.emptySet(), entities, entity, superType, (Class)null, embedded, skip);

    try {
        Class e = Class.forName("com.egopulse.querydsl.mongodb.Point");
        conf.addCustomType(Double[].class, e);
        return conf;
    } catch (ClassNotFoundException var9) {
        throw new IllegalStateException(var9);
    }
}
 
开发者ID:egopulse,项目名称:querydsl-mongodb-async,代码行数:17,代码来源:MongoAnnotationProcessor.java

示例3: QueryImpl

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * Creates a Query for the given type and collection
 *
 * @param clazz the type to return
 * @param coll  the collection to query
 * @param ds    the Datastore to use
 */
public QueryImpl(final Class<T> clazz, final DBCollection coll, final Datastore ds) {
    super(CriteriaJoin.AND);

    setQuery(this);
    this.clazz = clazz;
    this.ds = ((org.mongodb.morphia.DatastoreImpl) ds);
    dbColl = coll;
    cache = this.ds.getMapper().createEntityCache();

    final MappedClass mc = this.ds.getMapper().getMappedClass(clazz);
    final Entity entAn = mc == null ? null : mc.getEntityAnnotation();
    if (entAn != null) {
        getOptions().readPreference(this.ds.getMapper().getMappedClass(clazz).getEntityAnnotation().queryNonPrimary()
                   ? ReadPreference.secondaryPreferred()
                   : null);
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:25,代码来源:QueryImpl.java

示例4: getFieldsObject

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
@Override
@Deprecated
public DBObject getFieldsObject() {
    DBObject projection = getOptions().getProjection();
    if (projection == null || projection.keySet().size() == 0) {
        return null;
    }

    final MappedClass mc = ds.getMapper().getMappedClass(clazz);

    Entity entityAnnotation = mc.getEntityAnnotation();
    final BasicDBObject fieldsFilter = copy(projection);

    if (includeFields && entityAnnotation != null && !entityAnnotation.noClassnameStored()) {
        fieldsFilter.put(Mapper.CLASS_NAME_FIELDNAME, 1);
    }

    return fieldsFilter;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:20,代码来源:QueryImpl.java

示例5: check

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
@Override
public void check(final Mapper mapper, final MappedClass mc, final Set<ConstraintViolation> ve) {

    if (mc.getEntityAnnotation() != null && mc.getEmbeddedAnnotation() != null) {
        ve.add(new ConstraintViolation(Level.FATAL, mc, getClass(), format("Cannot have both @%s and @%s annotation at class level.",
            Entity.class.getSimpleName(), Embedded.class.getSimpleName())));
    }

}
 
开发者ID:mongodb,项目名称:morphia,代码行数:10,代码来源:EntityAndEmbed.java

示例6: update

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * Update mappings based on fields/annotations.
 */
// TODO: Remove this and make these fields dynamic or auto-set some other way
public void update() {
    embeddedAn = (Embedded) getAnnotation(Embedded.class);
    entityAn = (Entity) getFirstAnnotation(Entity.class);
    // polymorphicAn = (Polymorphic) getAnnotation(Polymorphic.class);
    final List<MappedField> fields = getFieldsAnnotatedWith(Id.class);
    if (fields != null && !fields.isEmpty()) {
        idField = fields.get(0).getField();
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:14,代码来源:MappedClass.java

示例7: validate

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
@Override
protected void validate(final Class<?> type, final Object value, final List<ValidationFailure> validationFailures) {
    if (value.getClass().getAnnotation(Entity.class) == null) {
        validationFailures.add(new ValidationFailure(format("When type is a Key the value should be an annotated entity. "
                                                            + "Value '%s' was a %s", value, value.getClass())));

    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:9,代码来源:EntityAnnotatedValueValidator.java

示例8: getWriteConcern

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * Gets the write concern for entity or returns the default write concern for this datastore
 *
 * @param clazzOrEntity the class or entity to use when looking up the WriteConcern
 */
private WriteConcern getWriteConcern(final Object clazzOrEntity) {
    WriteConcern wc = defConcern;
    if (clazzOrEntity != null) {
        final Entity entityAnn = getMapper().getMappedClass(clazzOrEntity).getEntityAnnotation();
        if (entityAnn != null && entityAnn.concern().length() != 0) {
            wc = WriteConcern.valueOf(entityAnn.concern());
        }
    }

    return wc;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:17,代码来源:DatastoreImpl.java

示例9: EntityScanner

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * Creates an EntityScanner using the given Morphia instance with the given predicate.
 *
 * @param m         the Morphia instance
 * @param predicate the Predicate to use when determining which classes to map.
 */
public EntityScanner(final Morphia m, final Predicate<String> predicate) {
    Predicate<String> localPredicate = predicate;
    if (localPredicate == null) {
        localPredicate = Predicates.alwaysTrue();
    }
    Assert.parametersNotNull("m, predicate", m, localPredicate);
    final ConfigurationBuilder conf = new ConfigurationBuilder();
    conf.setScanners(new TypeElementsScanner(), new TypeAnnotationsScanner());

    final Set<URL> s = new HashSet<URL>();
    s.addAll(ClasspathHelper.forClassLoader());
    s.addAll(ClasspathHelper.forJavaClassPath());
    final Iterator<URL> iterator = s.iterator();
    while (iterator.hasNext()) {
        final URL url = iterator.next();
        if (url.getPath().endsWith("jnilib")) {
            iterator.remove();
        }
    }
    conf.setUrls(new ArrayList<URL>(s));

    conf.filterInputsBy(localPredicate);
    conf.addScanners(new SubTypesScanner());

    final Reflections r = new Reflections(conf);

    final Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class);
    for (final Class<?> c : entities) {
        m.map(c);
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:38,代码来源:EntityScanner.java

示例10: getClasses

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * Return classes from a package name.
 * @param packageName
 * @return list of class
 */
public static Set<Class<?>> getClasses(final String packageName) {
    Reflections reflections = new Reflections(packageName);
    return reflections.getTypesAnnotatedWith(Entity.class);

}
 
开发者ID:ganchix,项目名称:morphia-spring-boot-starter,代码行数:11,代码来源:MorphiaUtils.java

示例11: entityAnnotation

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
@Override
public Class entityAnnotation() {
    return (Entity.class);
}
 
开发者ID:actframework,项目名称:act-storage,代码行数:5,代码来源:MorphiaDbHooker.java

示例12: getEntityAnnotation

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * @return the entityAn
 */
public Entity getEntityAnnotation() {
    return entityAn;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:7,代码来源:MappedClass.java

示例13: getClassEntityAnnotation

import org.mongodb.morphia.annotations.Entity; //导入依赖的package包/类
/**
 * Returns the @Entity annotation on a Class if present
 *
 * @param c the class to examine
 * @return the annotation.  may be null.
 */
public static Entity getClassEntityAnnotation(final Class c) {
    return getAnnotation(c, Entity.class);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:10,代码来源:ReflectionUtils.java


注:本文中的org.mongodb.morphia.annotations.Entity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。