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

com.github.alittlehuang.data.jpa.util.JpaHelper Maven / Gradle / Ivy

The newest version!
package com.github.alittlehuang.data.jpa.util;

import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;

/**
 * @author ALittleHuang
 */
public class JpaHelper {

    public static  Path getPath(Root root, String[] attributeNames) {
        Path path = root;
        for ( String attributeName : attributeNames ) {
            path = path.get(attributeName);
        }
        return path;
    }


    public static  boolean hasAttributeNames(Root root, String attributeNames) {
        return hasAttributeNames(root, attributeNames.split("\\."));
    }

    public static  boolean hasAttributeNames(Root root, String[] attributeNames) {
        try {
            getPath(root, attributeNames);
        } catch ( IllegalArgumentException e ) {
            return false;
        }
        return true;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy