[Spring boot] Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: ??? is not mapped 오류

seul·2020년 1월 5일
0

SpringBoot

목록 보기
2/3

[Spring boot] Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: ??? is not mapped 오류

해결 방법

Members.java를 통해 Entity를 설정했고 createQuery를 작성할 땐 아무생각 없이 members라고 적었는데, 이 부분에서 오류가 발생했다. 꼭 query에서 테이블명 쓸 때, 정확한 클래스명 사용할 것

[^출처]: https://matthew.kr/spring-boot-jpa%EC%97%90%EC%84%9C-update-%EC%BF%BC%EB%A6%AC-%EC%82%AC%EC%9A%A9%EC%8B%9C-xxx-is-not-mapped-%EC%97%90%EB%9F%AC-%EB%B0%9C%EC%83%9D%EC%8B%9C-%EB%8C%80%EC%B2%98%EB%B0%A9%EB%B2%95/

Members.java

package com.market.webservice.domain.members;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.market.webservice.domain.BaseTimeEntity;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
public class Members extends BaseTimeEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Column(columnDefinition = "TEXT", nullable = false)
	private String userID;

	private String userPassword;
	private String userNickname;
	private String userMobile;

	@Builder
	public Members(String userID, String userPassword, String userNickname, String userMobile) {
		this.userID = userID;
		this.userPassword = userPassword;
		this.userNickname = userNickname;
		this.userMobile = userMobile;
	}
}

UserDetailServiceImpl.java (수정 후)

List<Members> findMembers = em
				.createQuery("select m from Members m where m.userID = :userID",Members.class)
				.setParameter("userID", s)
				.getResultList();
profile
무한삽질로그

0개의 댓글