我有一些问题。
我刚刚将原始查询放到spring jpa。
但它会抛出错误idk为什么
以下是我的疑问:
查看创建查询
使用 Spring boot 1.5.2 和MariaDB 10.1.2
CREATE OR REPLACE VIEW `access_logs_hosts_view` AS
SELECT
url_id,
COUNT(0) AS access,
IFNULL(SUBSTRING_INDEX(REGEXP_REPLACE(referrer,'https?://',''),'/',1),'unknown') AS referrer
FROM
access_logs
GROUP BY
url_id
SUBSTRING_INDEX(REGEXP_REPLACE(`access_logs`.`referrer`,'https?://',''),'/',1)
ORDER BY access DESC
和方法:
@Query(value = "SELECT * FROM access_logs_hosts_view ", nativeQuery = true)
List<Map<String, Object>> findCountAndReferrerByURL();
application.yml
type: org.apache.tomcat.jdbc.pool.DataSource
driver-class-name: org.mariadb.jdbc.Driver
我的最终目标是使用一个本机查询并在没有查看的情况下获取数据。
SELECT
COUNT(0) AS access,
ifnull(SUBSTRING_INDEX(REGEXP_REPLACE(referrer,'https?://',''),'/',1),"unknown") AS referrer
FROM access_logs
WHERE url_id = ?1
GROUP BY SUBSTRING_INDEX(REGEXP_REPLACE(referrer,'https?://',''),'/',1)
ORDER BY access DESC