JPA QuerySyntaxException:XXX is not mapped
来源:互联网 发布:网络课程看了有用吗 编辑:程序博客网 时间:2024/06/09 16:01
1、问题
Caused by: java.lang.IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException: t_group is not mapped [delete from t_group i where i.userId = ?1 and i.Id =?2]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1364)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:294)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at com.sun.proxy.$Proxy38.createQuery(Unknown Source)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at com.sun.proxy.$Proxy38.createQuery(Unknown Source)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:69)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.fromQueryAnnotation(SimpleJpaQuery.java:132)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:114)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:160)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:280)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:148)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 36 more
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: t_group is not mapped [delete from t_group i where i.userId = ?1 and i.Id =?2]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
2、背景
public interface AppGroupRepositoryextends JpaRepository<AppGroup, Long> {
@Modifying
@Query("delete from t_group i where i.userId = ?1 and i.Id =?2")
public void deleteGroup(LonguserId,Long Id) ;
。。。。。。。。。。。。。。。。。。。。
@Entity
@Table(name = "t_group")
public class AppGroupimplements java.io.Serializable,IId{
3、解决办法
public interface AppGroupRepository extends JpaRepository<AppGroup, Long> {
@Modifying
@Query("delete fromAppGroupi where i.userId = ?1 and i.Id =?2")
public void deleteGroup(Long userId,Long Id) ;
@Query(value="select t1.role from t_um_role t1 where t1.status ='1' ",nativeQuery=true)
4. JPQL
select name ,age from user; //原生SQL语句
select u.name,u.age from User u; //JPQL语句
select u from User u; //JPQL语句
JPQL语句是在EJB实体空间中面向对象,属性进行操作
JPQL必须由JPA的JPQL解析器解析为SQL才能执行,必须先获取Query对象
- JPA QuerySyntaxException:XXX is not mapped
- ast.QuerySyntaxException: *** is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: XXX is not mapped [from XXX]
- org.hibernate.hql.ast.QuerySyntaxException: xxx is not mapped [from xxx]
- org.hibernate.hql.ast.QuerySyntaxException: xxx is not mapped [from xxx]
- org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped [from XXX]
- Hibernate查询报错:org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped
- ast QuerySyntaxException: user is not mapped
- hibernate XXX is not mapped
- org.hibernate.hql.ast.QuerySyntaxException is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: myaddressbook is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: Enroll is not mapped.
- org.hibernate.hql.ast.QuerySyntaxException: ? is not mapped
- org.hibernate.hql.ast.QuerySyntaxException:is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常总结 .
- org.hibernate.hql.ast.QuerySyntaxException is not mapped异常
- org.hibernate.hql.ast.QuerySyntaxException: Person is not mapped
- 网站数据统计分析系统之后端脚本之OpenResty简介
- jtable根据内容自动调整列宽
- springmvc基本原理
- 用俄罗斯方块入门EasyX库
- dtd是什么,为什么要用?
- JPA QuerySyntaxException:XXX is not mapped
- Android Error:(1, 0) Your project path contains non-ASCII characters.
- tap interfaces disabled in linux bridge
- 软件测试较好的学习网站
- JS中Array对象和String对象的常用方法
- List<?> 转换为 List<实体类>
- Android studio连接夜神
- 数据库设计之三大范式
- 从零开始学习Java Web(六):session和cookie