use of com.querydsl.core.types.PathMetadata in project querydsl by querydsl.
the class CollectionPathBase method newInstance.
@SuppressWarnings("unchecked")
protected Q newInstance(Class<Q> queryType, PathMetadata pm) {
try {
if (constructor == null) {
if (Constants.isTyped(queryType)) {
try {
constructor = queryType.getDeclaredConstructor(Class.class, PathMetadata.class, PathInits.class);
usePathInits = true;
} catch (NoSuchMethodException e) {
constructor = queryType.getDeclaredConstructor(Class.class, PathMetadata.class);
}
} else {
try {
constructor = queryType.getDeclaredConstructor(PathMetadata.class, PathInits.class);
usePathInits = true;
} catch (NoSuchMethodException e) {
constructor = queryType.getDeclaredConstructor(PathMetadata.class);
}
}
constructor.setAccessible(true);
}
if (Constants.isTyped(queryType)) {
if (usePathInits) {
return (Q) constructor.newInstance(getElementType(), pm, inits);
} else {
return (Q) constructor.newInstance(getElementType(), pm);
}
} else {
if (usePathInits) {
return (Q) constructor.newInstance(pm, inits);
} else {
return (Q) constructor.newInstance(pm);
}
}
} catch (NoSuchMethodException e) {
throw new ExpressionException(e);
} catch (InstantiationException e) {
throw new ExpressionException(e);
} catch (IllegalAccessException e) {
throw new ExpressionException(e);
} catch (InvocationTargetException e) {
throw new ExpressionException(e);
}
}
use of com.querydsl.core.types.PathMetadata in project spring-data-mongodb by spring-projects.
the class SpringDataMongodbSerializer method getPropertyForPotentialDbRef.
/**
* Checks the given {@literal path} for referencing the {@literal id} property of a {@link DBRef} referenced object.
* If so it returns the referenced {@link MongoPersistentProperty} of the {@link DBRef} instead of the {@literal id}
* property.
*
* @param path
* @return
*/
private MongoPersistentProperty getPropertyForPotentialDbRef(Path<?> path) {
if (path == null) {
return null;
}
MongoPersistentProperty property = getPropertyFor(path);
PathMetadata metadata = path.getMetadata();
if (property != null && property.isIdProperty() && metadata != null && metadata.getParent() != null) {
return getPropertyFor(metadata.getParent());
}
return property;
}
Aggregations