最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JPA添加Pageable實(shí)現(xiàn)翻頁(yè)時(shí)報(bào)錯(cuò)的問題

 更新時(shí)間:2021年09月16日 10:44:21   作者:alex_fung  
這篇文章主要介紹了解決JPA添加Pageable實(shí)現(xiàn)翻頁(yè)時(shí)報(bào)錯(cuò)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

JPA添加Pageable實(shí)現(xiàn)翻頁(yè)時(shí)報(bào)錯(cuò)

@Query("from Subject where name like CONCAT('%',:name,'%') and isDelete = 0 order by createTime desc")
Page<Subject> findSubjectByName(@Param("name") String name, Pageable page);

報(bào)錯(cuò):

select count(where) from com.swj.entity.Subject where name like CONCAT('%',:name,'%') and isDelete = 0

添加別名就可以解決

@Query("select t from Subject t where t.name like CONCAT('%',:name,'%') and t.isDelete = 0 order by createTime desc")
Page<Subject> findSubjectByName(@Param("name") String name, Pageable page);

Spring JPA異常的處理

Exception in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: Unknown entity: com.ecs.model.User; nested exception is java.lang.IllegalArgumentException: Unknown entity: com.ecs.model.User
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:381)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:418)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy14.save(Unknown Source)
at ecs.Test1.main(Test1.java:43)
Caused by: java.lang.IllegalArgumentException: Unknown entity: com.ecs.model.User
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:878)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:291)
at com.sun.proxy.$Proxy13.persist(Unknown Source)
at com.ecs.dao.UserDaoImpl.save(UserDaoImpl.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
... 6 more

解決方法

把persistence.xml放在src下的META-INF文件中

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • springboot優(yōu)雅獲取前端參數(shù)的方法詳解

    springboot優(yōu)雅獲取前端參數(shù)的方法詳解

    現(xiàn)在的項(xiàng)目基本上都是前后端分離的項(xiàng)目,如何打通前后端,接收前端傳過來的參數(shù)呢,這篇文章小編就來和大家詳細(xì)介紹一下springboot如何優(yōu)雅的獲取前端參數(shù)吧
    2024-03-03
  • 詳細(xì)分析Java Lambda表達(dá)式

    詳細(xì)分析Java Lambda表達(dá)式

    這篇文章主要介紹了Java Lambda表達(dá)式的相關(guān)資料,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • Spring?零基礎(chǔ)入門WebFlux框架體系

    Spring?零基礎(chǔ)入門WebFlux框架體系

    Spring5發(fā)布有兩年了,隨Spring5一起發(fā)布了一個(gè)和Spring?WebMvc同級(jí)的Spring?WebFlux。這是一個(gè)支持反應(yīng)式編程模型的新框架體系。反應(yīng)式模型區(qū)別于傳統(tǒng)的MVC最大的不同是異步的、事件驅(qū)動(dòng)的、非阻塞的,這使得應(yīng)用程序的并發(fā)性能會(huì)大大提高,單位時(shí)間能夠處理更多的請(qǐng)求
    2022-07-07
  • java.io.EOFException產(chǎn)生原因及解決方法(附代碼)

    java.io.EOFException產(chǎn)生原因及解決方法(附代碼)

    java.io.EOFException表示在讀取數(shù)據(jù)時(shí)突然遇到了文件或流的末尾,也就是說客戶端或服務(wù)器已經(jīng)關(guān)閉了連接,但是你還在嘗試讀取數(shù)據(jù),這篇文章主要給大家介紹了關(guān)于java.io.EOFException產(chǎn)生原因及解決的相關(guān)資料,需要的朋友可以參考下
    2023-09-09
  • Java異常處理try?catch的基本使用

    Java異常處理try?catch的基本使用

    大家好,本篇文章主要講的是Java異常處理try?catch的基本使用,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-02-02
  • springboot后端存儲(chǔ)富文本內(nèi)容的思路與步驟(含圖片內(nèi)容)

    springboot后端存儲(chǔ)富文本內(nèi)容的思路與步驟(含圖片內(nèi)容)

    在所有的編輯器中,大概最受歡迎的就是富文本編輯器和MarkDown編輯器了,下面這篇文章主要給大家介紹了關(guān)于springboot后端存儲(chǔ)富文本內(nèi)容的思路與步驟的相關(guān)資料,需要的朋友可以參考下
    2023-04-04
  • Java長(zhǎng)度不足左位補(bǔ)0的3種實(shí)現(xiàn)方法

    Java長(zhǎng)度不足左位補(bǔ)0的3種實(shí)現(xiàn)方法

    這篇文章主要介紹了Java長(zhǎng)度不足左位補(bǔ)0的3種實(shí)現(xiàn)方法小結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • Java使用Filter實(shí)現(xiàn)登錄驗(yàn)證

    Java使用Filter實(shí)現(xiàn)登錄驗(yàn)證

    本文主要介紹了Java使用Filter實(shí)現(xiàn)登錄驗(yàn)證,Filter類似于門衛(wèi),你在進(jìn)入之前門衛(wèi)需要盤查你,身份合法進(jìn)入,身份不合法攔截,感興趣的可以了解一下
    2023-11-11
  • 淺談SpringCloud?Alibaba和SpringCloud的區(qū)別

    淺談SpringCloud?Alibaba和SpringCloud的區(qū)別

    這篇文章主要介紹了淺談SpringCloud?Alibaba和SpringCloud的區(qū)別,Spring?Cloud?Netflix框架也屬于Spring?Cloud,但是Netflix并不是由spring來進(jìn)行開發(fā)的,需要的朋友可以參考下
    2023-05-05
  • java后臺(tái)如何利用Pattern提取所需字符詳解

    java后臺(tái)如何利用Pattern提取所需字符詳解

    這篇文章主要給大家介紹了關(guān)于java后臺(tái)如何利用Pattern提取所需字符的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-01-01

最新評(píng)論

凌海市| 望都县| 比如县| 安仁县| 平谷区| 无极县| 如东县| 拜泉县| 濮阳市| 高安市| 静安区| 清徐县| 迭部县| 贵阳市| 汤阴县| 宁化县| 广灵县| 萨嘎县| 六枝特区| 施甸县| 遂宁市| 五莲县| 开原市| 金塔县| 威海市| 东乡| 琼海市| 马公市| 孟村| 南丹县| 罗定市| 泊头市| 临邑县| 万全县| 洛隆县| 独山县| 二连浩特市| 龙川县| 扬中市| 邯郸县| 榆林市|