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

com.github.aqiu202.starters.jpa.sql.NativeSqlQuery Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package com.github.aqiu202.starters.jpa.sql;

import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 * 自定义SQL查询封装
 * @author AQIU 2018/11/26 10:26 AM
 **/
public final class NativeSqlQuery extends AbstractQuery {

    private NativeSqlQuery(EntityManager entityManager) {
        super(entityManager);
    }

    public static  NativeSqlQuery of(EntityManager entityManager) {
        return new NativeSqlQuery<>(entityManager);
    }

    @Override
    public Query createQuery(String sql) {
        return this.entityManager.createNativeQuery(sql);
    }

    @Override
    protected String getCountSql(String sql) {
        return "SELECT count(*) FROM (" + sql + ")";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy