use of org.mongodb.morphia.annotations.Entity in project morphia by mongodb.
the class Morphia method mapPackage.
/**
* Tries to map all classes in the package specified.
*
* @param packageName the name of the package to process
* @param ignoreInvalidClasses specifies whether to ignore classes in the package that cannot be mapped
* @return the Morphia instance
*/
public synchronized Morphia mapPackage(final String packageName, final boolean ignoreInvalidClasses) {
try {
for (final Class clazz : ReflectionUtils.getClasses(packageName, mapper.getOptions().isMapSubPackages())) {
try {
final Embedded embeddedAnn = ReflectionUtils.getClassEmbeddedAnnotation(clazz);
final Entity entityAnn = ReflectionUtils.getClassEntityAnnotation(clazz);
final boolean isAbstract = Modifier.isAbstract(clazz.getModifiers());
if ((entityAnn != null || embeddedAnn != null) && !isAbstract) {
map(clazz);
}
} catch (final MappingException ex) {
if (!ignoreInvalidClasses) {
throw ex;
}
}
}
return this;
} catch (IOException e) {
throw new MappingException("Could not get map classes from package " + packageName, e);
} catch (ClassNotFoundException e) {
throw new MappingException("Could not get map classes from package " + packageName, e);
}
}
use of org.mongodb.morphia.annotations.Entity in project morphia by mongodb.
the class QueryImpl method getFieldsObject.
@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;
}
use of org.mongodb.morphia.annotations.Entity in project querydsl by querydsl.
the class MorphiaAnnotationProcessor method createConfiguration.
@Override
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class<? extends Annotation> entities = QueryEntities.class;
Class<? extends Annotation> entity = Entity.class;
Class<? extends Annotation> superType = QuerySupertype.class;
Class<? extends Annotation> embedded = Embedded.class;
Class<? extends Annotation> skip = Transient.class;
DefaultConfiguration conf = new DefaultConfiguration(roundEnv, processingEnv.getOptions(), Collections.<String>emptySet(), entities, entity, superType, null, embedded, skip);
try {
// Point is an Expression<Double[]>
@SuppressWarnings("unchecked") Class<? extends Expression<Double[]>> cl = (Class<? extends Expression<Double[]>>) Class.forName("com.querydsl.mongodb.Point");
conf.addCustomType(Double[].class, cl);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
return conf;
}
Aggregations