All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.robertomike.hefesto.utils.HibernateUtils Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy