org.hibernate.query.sqm.UnknownEntityException

padde479

Bekanntes Mitglied
Hallo zusammen,
ich versuche gerade, mir Angular, Spring Boot und MySQL etwas näher zu bringen. Wenn ich allerdings mein Projekt ausführe, erhalte ich diverse Exceptions derart, dass eine Entität nicht aufgelöst werden kann. Hierzu habe ich folgende Klassen:

Java:
package com.inn.cafe.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;

import com.inn.cafe.POJO.User;

public interface UserDao extends JpaRepository<User, Integer> {
    User findByEmailId(@Param("email") String email);
}

Java:
package com.inn.cafe.POJO;

import java.io.Serializable;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import jakarta.persistence.*;
import lombok.Data;

@NamedQuery(name = "User.findByEmailId", query = "SELECT u.name FROM cafe.user u WHERE u.email = `email`")

@Data
@Entity
@DynamicUpdate
@DynamicInsert
@Table(name = "user")
public class User implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 3839381239439398222L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    
    @Column(name = "name")
    private String name;
    
    @Column(name = "contactNumber")
    private String contactNumber;
    
    @Column(name = "email")
    private String email;
    
    @Column(name = "password")
    private String password;
    
    @Column(name = "status")
    private String status;
    
    @Column(name = "role")
    private String role;
}

Wenn ich in der Klasse UserDao die Zeile 9 entferne und in der Klasse User die Zeile 11, dann kann ich mein Projekt starten. Kann mir evtl. jemand weiterhelfen und sagen, wo der Fehler liegt? Lt. Excpetion ist es ein Fehler in named queries, aber die sieht meiner Meinung nach gut aus.

Danke für eure Hilfe!

Hier die Exception:
Code:
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.2)

2023-08-08T20:17:04.423+02:00  INFO 13460 --- [           main] c.i.c.CafeManagementSystemApplication    : Starting CafeManagementSystemApplication using Java 18.0.1.1 with PID 13460 (C:\Users\GeilerMacker\Downloads\com.inn.cafe\target\classes started by GeilerMacker in C:\Users\GeilerMacker\Downloads\com.inn.cafe)
2023-08-08T20:17:04.425+02:00  INFO 13460 --- [           main] c.i.c.CafeManagementSystemApplication    : No active profile set, falling back to 1 default profile: "default"
2023-08-08T20:17:04.963+02:00  INFO 13460 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-08-08T20:17:05.025+02:00  INFO 13460 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 53 ms. Found 1 JPA repository interfaces.
2023-08-08T20:17:05.509+02:00  INFO 13460 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-08-08T20:17:05.517+02:00  INFO 13460 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-08-08T20:17:05.517+02:00  INFO 13460 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.11]
2023-08-08T20:17:05.601+02:00  INFO 13460 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-08-08T20:17:05.603+02:00  INFO 13460 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1137 ms
2023-08-08T20:17:05.746+02:00  INFO 13460 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-08-08T20:17:05.789+02:00  INFO 13460 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.2.6.Final
2023-08-08T20:17:05.791+02:00  INFO 13460 --- [           main] org.hibernate.cfg.Environment            : HHH000406: Using bytecode reflection optimizer
2023-08-08T20:17:05.895+02:00  INFO 13460 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : bytebuddy
2023-08-08T20:17:05.985+02:00  INFO 13460 --- [           main] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2023-08-08T20:17:05.998+02:00  INFO 13460 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-08-08T20:17:06.125+02:00  INFO 13460 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@3bbb8c16
2023-08-08T20:17:06.127+02:00  INFO 13460 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-08-08T20:17:06.145+02:00  WARN 13460 --- [           main] org.hibernate.orm.deprecation            : HHH90000026: MySQL8Dialect has been deprecated; use org.hibernate.dialect.MySQLDialect instead
2023-08-08T20:17:06.294+02:00  INFO 13460 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : bytebuddy
2023-08-08T20:17:06.746+02:00  INFO 13460 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-08-08T20:17:06.882+02:00 ERROR 13460 --- [           main] org.hibernate.orm.query                  : HHH90003001: Error in named query: User.findByEmailId

org.hibernate.query.sqm.UnknownEntityException: Could not resolve root entity 'cafe.user'
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitRootEntity(SemanticQueryBuilder.java:1960) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitRootEntity(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.grammars.hql.HqlParser$RootEntityContext.accept(HqlParser.java:2473) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitEntityWithJoins(SemanticQueryBuilder.java:1874) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitFromClause(SemanticQueryBuilder.java:1865) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuery(SemanticQueryBuilder.java:1141) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:937) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.grammars.hql.HqlParser$QuerySpecExpressionContext.accept(HqlParser.java:1818) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:931) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.grammars.hql.HqlParser$SimpleQueryGroupContext.accept(HqlParser.java:1711) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectStatement(SemanticQueryBuilder.java:418) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitStatement(SemanticQueryBuilder.java:377) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.SemanticQueryBuilder.buildSemanticModel(SemanticQueryBuilder.java:295) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:81) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.lambda$checkNamedQueries$5(NamedObjectRepositoryImpl.java:242) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:141) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:128) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.checkNamedQueries(NamedObjectRepositoryImpl.java:239) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.validateNamedQueries(NamedObjectRepositoryImpl.java:212) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.spi.QueryEngine.validateNamedQueries(QueryEngine.java:220) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryObserverForNamedQueryValidation.sessionFactoryCreated(SessionFactoryObserverForNamedQueryValidation.java:39) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:292) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1155) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
    at com.inn.cafe.CafeManagementSystemApplication.main(CafeManagementSystemApplication.java:10) ~[classes/:na]

2023-08-08T20:17:06.889+02:00 ERROR 13460 --- [           main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
2023-08-08T20:17:06.889+02:00  WARN 13460 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
2023-08-08T20:17:06.889+02:00  INFO 13460 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-08-08T20:17:06.897+02:00  INFO 13460 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2023-08-08T20:17:06.899+02:00  INFO 13460 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-08-08T20:17:06.910+02:00  INFO 13460 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-08-08T20:17:06.928+02:00 ERROR 13460 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1155) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
    at com.inn.cafe.CafeManagementSystemApplication.main(CafeManagementSystemApplication.java:10) ~[classes/:na]
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.11.jar:6.0.11]
    ... 16 common frames omitted
Caused by: org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.validateNamedQueries(NamedObjectRepositoryImpl.java:221) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.spi.QueryEngine.validateNamedQueries(QueryEngine.java:220) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryObserverForNamedQueryValidation.sessionFactoryCreated(SessionFactoryObserverForNamedQueryValidation.java:39) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:292) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.11.jar:6.0.11]
    ... 20 common frames omitted
    Suppressed: org.hibernate.query.sqm.UnknownEntityException: Could not resolve root entity 'cafe.user'
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitRootEntity(SemanticQueryBuilder.java:1960) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitRootEntity(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.grammars.hql.HqlParser$RootEntityContext.accept(HqlParser.java:2473) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitEntityWithJoins(SemanticQueryBuilder.java:1874) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitFromClause(SemanticQueryBuilder.java:1865) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuery(SemanticQueryBuilder.java:1141) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:937) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.grammars.hql.HqlParser$QuerySpecExpressionContext.accept(HqlParser.java:1818) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:931) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.grammars.hql.HqlParser$SimpleQueryGroupContext.accept(HqlParser.java:1711) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectStatement(SemanticQueryBuilder.java:418) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitStatement(SemanticQueryBuilder.java:377) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.SemanticQueryBuilder.buildSemanticModel(SemanticQueryBuilder.java:295) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:81) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.NamedObjectRepositoryImpl.lambda$checkNamedQueries$5(NamedObjectRepositoryImpl.java:242) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:141) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:128) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.NamedObjectRepositoryImpl.checkNamedQueries(NamedObjectRepositoryImpl.java:239) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.NamedObjectRepositoryImpl.validateNamedQueries(NamedObjectRepositoryImpl.java:212) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        ... 29 common frames omitted
 

padde479

Bekanntes Mitglied
Ok, danke. Wenn ich aber Zeile 11 in User ändere in
Java:
@NamedQuery(name = "User.findByEmailId", query = "select u from User u where u.email=:@email")
ändere, erhalte ich die folgende Ausgabe:
Code:
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.2)

2023-08-08T21:15:23.712+02:00  INFO 24180 --- [           main] c.i.c.CafeManagementSystemApplication    : Starting CafeManagementSystemApplication using Java 18.0.1.1 with PID 24180 (C:\Users\GeilerMacker\Downloads\com.inn.cafe\target\classes started by GeilerMacker in C:\Users\GeilerMacker\Downloads\com.inn.cafe)
2023-08-08T21:15:23.715+02:00  INFO 24180 --- [           main] c.i.c.CafeManagementSystemApplication    : No active profile set, falling back to 1 default profile: "default"
2023-08-08T21:15:24.230+02:00  INFO 24180 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-08-08T21:15:24.287+02:00  INFO 24180 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 49 ms. Found 1 JPA repository interfaces.
2023-08-08T21:15:24.788+02:00  INFO 24180 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-08-08T21:15:24.798+02:00  INFO 24180 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-08-08T21:15:24.798+02:00  INFO 24180 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.11]
2023-08-08T21:15:24.884+02:00  INFO 24180 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-08-08T21:15:24.885+02:00  INFO 24180 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1123 ms
2023-08-08T21:15:25.030+02:00  INFO 24180 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-08-08T21:15:25.083+02:00  INFO 24180 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.2.6.Final
2023-08-08T21:15:25.085+02:00  INFO 24180 --- [           main] org.hibernate.cfg.Environment            : HHH000406: Using bytecode reflection optimizer
2023-08-08T21:15:25.201+02:00  INFO 24180 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : bytebuddy
2023-08-08T21:15:25.308+02:00  INFO 24180 --- [           main] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2023-08-08T21:15:25.321+02:00  INFO 24180 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-08-08T21:15:25.461+02:00  INFO 24180 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@3bbb8c16
2023-08-08T21:15:25.464+02:00  INFO 24180 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-08-08T21:15:25.484+02:00  WARN 24180 --- [           main] org.hibernate.orm.deprecation            : HHH90000026: MySQL8Dialect has been deprecated; use org.hibernate.dialect.MySQLDialect instead
2023-08-08T21:15:25.658+02:00  INFO 24180 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : bytebuddy
2023-08-08T21:15:26.103+02:00  INFO 24180 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
line 1:36 token recognition error at: '@'
2023-08-08T21:15:26.203+02:00 ERROR 24180 --- [           main] org.hibernate.orm.query                  : HHH90003001: Error in named query: User.findByEmailId

org.hibernate.query.SemanticException: A query exception occurred [select u from User u where u.email=:@email]
    at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:130) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:77) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.lambda$checkNamedQueries$5(NamedObjectRepositoryImpl.java:242) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:141) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:128) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.checkNamedQueries(NamedObjectRepositoryImpl.java:239) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.validateNamedQueries(NamedObjectRepositoryImpl.java:212) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.spi.QueryEngine.validateNamedQueries(QueryEngine.java:220) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryObserverForNamedQueryValidation.sessionFactoryCreated(SessionFactoryObserverForNamedQueryValidation.java:39) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:292) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1155) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
    at com.inn.cafe.CafeManagementSystemApplication.main(CafeManagementSystemApplication.java:10) ~[classes/:na]
Caused by: org.hibernate.query.sqm.ParsingException: line 1:36 token recognition error at: '@'
    at org.hibernate.query.hql.internal.StandardHqlTranslator$1.syntaxError(StandardHqlTranslator.java:46) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.Lexer.notifyListeners(Lexer.java:364) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:144) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.BufferedTokenStream.consume(BufferedTokenStream.java:136) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:537) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393) ~[antlr4-runtime-4.10.1.jar:4.10.1]
    at org.hibernate.grammars.hql.HqlParser.queryExpression(HqlParser.java:1723) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.grammars.hql.HqlParser.selectStatement(HqlParser.java:400) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.grammars.hql.HqlParser.statement(HqlParser.java:331) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:116) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    ... 35 common frames omitted

2023-08-08T21:15:26.210+02:00 ERROR 24180 --- [           main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
2023-08-08T21:15:26.210+02:00  WARN 24180 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
2023-08-08T21:15:26.211+02:00  INFO 24180 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-08-08T21:15:26.219+02:00  INFO 24180 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2023-08-08T21:15:26.221+02:00  INFO 24180 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-08-08T21:15:26.231+02:00  INFO 24180 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-08-08T21:15:26.249+02:00 ERROR 24180 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1155) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.11.jar:6.0.11]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
    at com.inn.cafe.CafeManagementSystemApplication.main(CafeManagementSystemApplication.java:10) ~[classes/:na]
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.11.jar:6.0.11]
    ... 16 common frames omitted
Caused by: org.hibernate.HibernateException: Errors in named queries: User.findByEmailId
    at org.hibernate.query.internal.NamedObjectRepositoryImpl.validateNamedQueries(NamedObjectRepositoryImpl.java:221) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.query.spi.QueryEngine.validateNamedQueries(QueryEngine.java:220) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryObserverForNamedQueryValidation.sessionFactoryCreated(SessionFactoryObserverForNamedQueryValidation.java:39) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:292) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.11.jar:6.0.11]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.11.jar:6.0.11]
    ... 20 common frames omitted
    Suppressed: org.hibernate.query.SemanticException: A query exception occurred [select u from User u where u.email=:@email]
        at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:130) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:77) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.NamedObjectRepositoryImpl.lambda$checkNamedQueries$5(NamedObjectRepositoryImpl.java:242) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:141) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:128) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.NamedObjectRepositoryImpl.checkNamedQueries(NamedObjectRepositoryImpl.java:239) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        at org.hibernate.query.internal.NamedObjectRepositoryImpl.validateNamedQueries(NamedObjectRepositoryImpl.java:212) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
        ... 29 common frames omitted
    Caused by: org.hibernate.query.sqm.ParsingException: line 1:36 token recognition error at: '@'
        at org.hibernate.query.hql.internal.StandardHqlTranslator$1.syntaxError(StandardHqlTranslator.java:46)
        at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
        at org.antlr.v4.runtime.Lexer.notifyListeners(Lexer.java:364)
        at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:144)
        at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169)
        at org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152)
        at org.antlr.v4.runtime.BufferedTokenStream.consume(BufferedTokenStream.java:136)
        at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:537)
        at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
        at org.hibernate.grammars.hql.HqlParser.queryExpression(HqlParser.java:1723)
        at org.hibernate.grammars.hql.HqlParser.selectStatement(HqlParser.java:400)
        at org.hibernate.grammars.hql.HqlParser.statement(HqlParser.java:331)
        at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:116)
        ... 35 common frames omitted
Was stimmt denn mit dem @-Zeichen nicht bzw. wie muss das Statement denn korrekt lauten?
 

padde479

Bekanntes Mitglied
Nächste Frage, sorry 😖 In der Klasse User ist die Annotation @Data eingebunden. Die Doku sagt dazu
Code:
Generates getters for all fields, a useful toString method, and hashCode and equals implementations that check all non-transient fields. Will also generate setters for all non-final fields, as well as a constructor.
In meiner Klasse UserServiceImpl habe ich folgende Methode stehen:
Java:
package com.inn.cafe.serviceImpl;

import java.util.Map;
import java.util.Objects;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.inn.cafe.POJO.User;
import com.inn.cafe.constents.CafeConstants;
import com.inn.cafe.dao.UserDao;
import com.inn.cafe.service.UserService;
import com.inn.cafe.utils.CafeUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;
    
    @Override
    public ResponseEntity<String> signup(Map<String, String> requestMap) {
        System.out.println("Inside signup");
        if (validateSignupMap(requestMap)) {
            User user = userDao.findByEmailId(requestMap.get("email"));
            if (Objects.isNull(user)) {
                userDao.save(null);
            } else {
                return CafeUtils.getResponseEntity("Email already exists", HttpStatus.BAD_REQUEST);
            }
        } else
            return CafeUtils.getResponseEntity(CafeConstants.INVALID_DATA, HttpStatus.BAD_REQUEST);
        return null;
    }

    private boolean validateSignupMap(Map<String, String> requestMap) {
        if (requestMap.containsKey("name") && requestMap.containsKey("contactNumber") && requestMap.containsKey("email")
                && requestMap.containsKey("password"))
            return true;
        else
            return false;
    }

    private User getUserFromMap(Map<String, String> requestMap) {
        User user = new User();
        user.setName(requestMap.get("name")); 
        user.setContactNumber(requestMap.get("contactNumber"));
        user.setEmail(requestMap.get("email"));
        user.getPassword(requestMap.get("password"));
        user.setStatus("false");
        user.setRole("user");
        return user;
    }
}
Jetzt bekomme ich die Fehlermeldung
Code:
The method setContactNumber(String) is undefined for the type User
angezeigt. Ich dachte aber, dass diese Methoden automatisch generiert werden durch die Annotation @Data.
 

padde479

Bekanntes Mitglied
Ok, man musste im Package Explorer im Projekt Maven Dependencies ausklappen, das lombok-<VERSION>.jar mit rechts anklicken und dann [Run As] > [Java Aplication] ausführen. Im sich öffnenden Installer den Pfad zur aktuellen eclipse.ini angeben, Install/Update ausführen und anschließend den Installer beenden. In Eclipse geht man anschließend auf [Project] > [Clean] und führt einen Restart von Eclipse durch. Dann entfällt der Fehler und die Methoden werden generiert.
 

thecain

Top Contributor
Nur die Lombok Annotationen zu verwenden die gebraucht werden (Getter, Setter, usw.) Oder kein Lombok einzusetzen bei der Klasse.
Equals und Hashcode implementiere ich, wenn nötig, mit der NaturalId. In deinem Fall also wahrscheinlich der E-mail
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
Avalon @Query Select Abfrage liefert falsche Werte (Spring Boot, JPA, Hibernate) Frameworks - Spring, Play, Blade, Vaadin & Co 3
W Kotlin: DB-Relationen in Spring Boot Data / Hibernate Frameworks - Spring, Play, Blade, Vaadin & Co 6
H Laden der Hibernate Cfg in .jar Frameworks - Spring, Play, Blade, Vaadin & Co 5
ExceptionOfExpectation Persistierung in Hibernate(SpringBoot) Frameworks - Spring, Play, Blade, Vaadin & Co 10
OnDemand Jasypt Hibernate 6 alternative gesucht Frameworks - Spring, Play, Blade, Vaadin & Co 3
D org.hibernate.LazyInitializationException Frameworks - Spring, Play, Blade, Vaadin & Co 2
krgewb Hibernate - deleteByXXX Frameworks - Spring, Play, Blade, Vaadin & Co 3
Z Postgres, Hibernate Seqencenummer wird wiederholt und verursacht PK-Fehler Frameworks - Spring, Play, Blade, Vaadin & Co 3
Z JPA, Hibernate, Postgres und Sequence-Nummern Frameworks - Spring, Play, Blade, Vaadin & Co 3
Z Hibernate & Postgres in Spring Boot (Syntaxprobleme) Frameworks - Spring, Play, Blade, Vaadin & Co 2
Z Spring Boot mit JPA;, Hibernate, Rest & Lombok Frameworks - Spring, Play, Blade, Vaadin & Co 8
OnDemand Jasypt Spring Boot HIbernate wie komme ich an den Key? Frameworks - Spring, Play, Blade, Vaadin & Co 4
OnDemand Hibernate Lazy Collection löschen Frameworks - Spring, Play, Blade, Vaadin & Co 7
H Hibernate Sql Abfrage loggen Spring mit log4j.properties Frameworks - Spring, Play, Blade, Vaadin & Co 2
OnDemand DTO <> Entity Hibernate Spring Boot Frameworks - Spring, Play, Blade, Vaadin & Co 28
S Spring JPA / Hibernate: save Methode arbeitet nicht Frameworks - Spring, Play, Blade, Vaadin & Co 2
R Spring Data: Hibernate liest nicht alle Ebenen Frameworks - Spring, Play, Blade, Vaadin & Co 5
S Spring Data Hibernate mehrfache Suchkriterien Frameworks - Spring, Play, Blade, Vaadin & Co 5
H Spring Boot, Hibernate und OAuth2 wie komme ich an den User? Frameworks - Spring, Play, Blade, Vaadin & Co 13
D Spring Hibernate Struts2 ? Frameworks - Spring, Play, Blade, Vaadin & Co 1
F JPA org.hibernate.LazyInitializationException / Spring @Transactional Frameworks - Spring, Play, Blade, Vaadin & Co 5
P Spring, Hibernate und JPA in einem Projekt Frameworks - Spring, Play, Blade, Vaadin & Co 4
I Nachladen mit Hibernate und Spring Frameworks - Spring, Play, Blade, Vaadin & Co 2
N MAVEN + Spring + JPA + Hibernate + JUnit4 Frameworks - Spring, Play, Blade, Vaadin & Co 5
E Tomcat mit Hibernate und Spring - Problem mit Connection Pool Frameworks - Spring, Play, Blade, Vaadin & Co 5
P Context initialization failed - mit Spring, JPA, Hibernate Frameworks - Spring, Play, Blade, Vaadin & Co 1
B Buchempfehlung für Groovy, Spring, Hibernate, SOAP, J2EE gesucht Frameworks - Spring, Play, Blade, Vaadin & Co 1
D Hibernate - Spring Roo Frameworks - Spring, Play, Blade, Vaadin & Co 0
Dit_ Springsource Toolsuit | Hibernate intergration Frameworks - Spring, Play, Blade, Vaadin & Co 1
J Test mit Hibernate und Spring Frameworks - Spring, Play, Blade, Vaadin & Co 5
D [InvalidDataAccessApiUsageException] Spring Data JPA / Hibernate Frameworks - Spring, Play, Blade, Vaadin & Co 1
B SpringMVC-EntityManagerFactory-Hibernate-Problem Frameworks - Spring, Play, Blade, Vaadin & Co 1
M Problem mit Hibernate und Spring Frameworks - Spring, Play, Blade, Vaadin & Co 0
R Projektübergreifende Entities mit Tomcat (Spring/JPA/Hibernate) Frameworks - Spring, Play, Blade, Vaadin & Co 2
N Wie manage ich unter Spring mehrere Datenbankverbindung mit Hibernate Frameworks - Spring, Play, Blade, Vaadin & Co 6
Y Sessionmanagement (ThreadLocal) in Hibernate via Spring möglich? Frameworks - Spring, Play, Blade, Vaadin & Co 2
C Aufgabe in OSGI/Hibernate/Spring-DM Frameworks - Spring, Play, Blade, Vaadin & Co 4
dunhillone Problem mit Spring & Hibernate Sessions Frameworks - Spring, Play, Blade, Vaadin & Co 2
dunhillone Problem mit Spring & Hibernate Sessions Frameworks - Spring, Play, Blade, Vaadin & Co 2
B Spring / Jpa / Hibernate -> java.lang.IllegalArgumentException: Unknown entity Frameworks - Spring, Play, Blade, Vaadin & Co 1
S Hibernate und JDBC über Spring Frameworks - Spring, Play, Blade, Vaadin & Co 3
ExceptionOfExpectation Die Parameter Übergabe für @Query()-Annotation in einer Repository Interface Frameworks - Spring, Play, Blade, Vaadin & Co 19
8u3631984 Frage @Query in Repository Frameworks - Spring, Play, Blade, Vaadin & Co 2
M Speichern letzter Query Frameworks - Spring, Play, Blade, Vaadin & Co 28
Dimax Spring Query +Thymeleaf Frameworks - Spring, Play, Blade, Vaadin & Co 5
P Spring JPA Query zusammensetzen Frameworks - Spring, Play, Blade, Vaadin & Co 2
J Spring data JPA Query Frameworks - Spring, Play, Blade, Vaadin & Co 2

Ähnliche Java Themen


Oben