Notice
Recent Posts
Recent Comments
Link
아님말고
[JPA] org.hibernate.hql.internal.ast.QuerySyntaxException: 엔티티명 is not mapped 본문
JPA
[JPA] org.hibernate.hql.internal.ast.QuerySyntaxException: 엔티티명 is not mapped
스타박씨 2022. 8. 29. 01:26아래 오류가 발생시 체크해봐야 할 부분
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:169) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:77) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:333) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3758) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3647) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:732) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:588) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:325) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:273) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:276) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:192) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
1case) 가장 많은 경우로 entity class 명으로 안한 경우
@Data
@Entity(name = "user")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column
private String name;
}
@Query(value = "select us from User us")
public List<User> selectJpqlUser();
2case) @Table 어노테이션 이용
@Data
@Entity(name = "user")
형태를 아래와 같이 변경
@Data
@Entity
@Table(name = "user")
public class User {
3case) datasource 설정이 잘 안되어져 있을때
'JPA' 카테고리의 다른 글
[JPA] Projection 의 다양한 방법들 (0) | 2022.09.15 |
---|---|
[JPA] QueryDSL 조회시 원하는 컬럼만 가져오기 (0) | 2022.09.14 |
[JPA] QueryDSL 초기 세팅 및 예제 (0) | 2022.09.09 |
[JPA] QueryDSL + multi datasource 설정 (0) | 2022.08.17 |
[JPA] query를 작성하는 방법들 (0) | 2022.08.10 |
Comments