
com.github.wenhao.jpa.specification.AbstractSpecification Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpa-spec Show documentation
Show all versions of jpa-spec Show documentation
A JAP Query By Specification framework.
The newest version!
package com.github.wenhao.jpa.specification;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.StringUtils;
import java.io.Serializable;
import javax.persistence.criteria.From;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Root;
abstract class AbstractSpecification implements Specification, Serializable {
public String getProperty(String property) {
if (property.contains(".")) {
return StringUtils.split(property, ".")[1];
}
return property;
}
public From getRoot(String property, Root root) {
if (property.contains(".")) {
String joinProperty = StringUtils.split(property, ".")[0];
return root.join(joinProperty, JoinType.LEFT);
}
return root;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy