io.github.robertomike.hefesto.utils.HibernateUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hefesto-hibernate Show documentation
Show all versions of hefesto-hibernate Show documentation
HefestoSql is an open-source Java library for creation of query with hibernate
The newest version!
package io.github.robertomike.hefesto.utils;
import jakarta.persistence.criteria.From;
import jakarta.persistence.criteria.Path;
public class HibernateUtils {
public static final String DOT_REGEX = "\\.";
public static Path getFieldFrom(From, ?> from, String field) {
if (!field.contains(".")) {
return from.get(field);
}
var split = field.split(DOT_REGEX);
Path path = null;
for (var o : split) {
if (path == null) {
path = from.get(o);
continue;
}
path = path.get(o);
}
return path;
}
}