get Select Active Query Sql for AbstractEntity - Java javax.persistence

Java examples for javax.persistence:EntityManager

Description

get Select Active Query Sql for AbstractEntity

Demo Code


import java.io.Serializable;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityManager;

public class Main{
    public static void main(String[] argv) throws Exception{
        Class entityType = String.class;
        System.out.println(getSelectActiveQuerySql(entityType));
    }// w  w w. j  a va 2 s . c o  m
    public static String getSelectActiveQuerySql(
            Class<? extends AbstractEntity> entityType) {
        if (entityType == null)
            return "";
        return "select e from " + entityType.getSimpleName()
                + " as e where e.active = true";
    }
}

Related Tutorials