@@ -19,6 +19,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -40,7 +41,15 @@ public class SimpleEntityPathResolver implements EntityPathResolver {
|
||||
|
||||
private final String querySuffix;
|
||||
|
||||
/**
|
||||
* Creates a new {@link SimpleEntityPathResolver} with the given query package suffix.
|
||||
*
|
||||
* @param querySuffix must not be {@literal null}.
|
||||
*/
|
||||
public SimpleEntityPathResolver(String querySuffix) {
|
||||
|
||||
Assert.notNull(querySuffix, "Query suffix must not be null!");
|
||||
|
||||
this.querySuffix = querySuffix;
|
||||
}
|
||||
|
||||
@@ -102,7 +111,9 @@ public class SimpleEntityPathResolver implements EntityPathResolver {
|
||||
private String getQueryClassName(Class<?> domainClass) {
|
||||
|
||||
String simpleClassName = ClassUtils.getShortName(domainClass);
|
||||
return String.format("%s%s.Q%s%s", domainClass.getPackage().getName(), querySuffix, getClassBase(simpleClassName),
|
||||
String packageName = domainClass.getPackage().getName();
|
||||
|
||||
return String.format("%s%s.Q%s%s", packageName, querySuffix, getClassBase(simpleClassName),
|
||||
domainClass.getSimpleName());
|
||||
}
|
||||
|
||||
@@ -116,10 +127,6 @@ public class SimpleEntityPathResolver implements EntityPathResolver {
|
||||
|
||||
String[] parts = shortName.split("\\.");
|
||||
|
||||
if (parts.length < 2) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return parts[0] + "_";
|
||||
return parts.length < 2 ? "" : parts[0] + "_";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,10 +22,14 @@ import com.querydsl.core.types.dsl.EntityPathBase;
|
||||
/**
|
||||
* Mimicks a class generated by Querydsl with a package suffix.
|
||||
*
|
||||
* @see org.springframework.data.querydsl.SimpleEntityPathResolverUnitTests
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
* @see org.springframework.data.querydsl.SimpleEntityPathResolverUnitTests
|
||||
*/
|
||||
public class QUser extends EntityPathBase<User> {
|
||||
|
||||
private static final long serialVersionUID = -2346766110501428367L;
|
||||
|
||||
public static final QUser user = new QUser("user");
|
||||
|
||||
public QUser(String user) {
|
||||
|
||||
Reference in New Issue
Block a user