org.postgresql.util.PSQLException:错误:关系“ userdetailsentity”不存在

时间:2019-05-12 10:54:33

标签: java spring spring-boot spring-data-jpa

我正在使用Spring Boot和PostgreSql开发应用程序。使用where子句执行select查询时出现以下错误

我正在存储库中执行此操作。我正在尝试通过本机查询使用其电子邮件ID来获取用户详细信息:

@Repository
@Transactional
public class RegistrationRepository {
        @Autowired
    EntityManager em;

     private Logger logger=LoggerFactory.getLogger(this.getClass());

     public UserDetailsEntity getUserDetails(String emailId) {
        Query query=em.createNativeQuery("select * from 
      UserDetailsEntity where userEmail=:userEmail",UserDetailsEntity.class);
        query.setParameter("userEmail", emailId);
        List result=query.getResultList();
        logger.info("result======>{}",result);
        return null;
    }
}

Entity class is given below:


package com.counselor.entities;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

@Entity
public class UserDetailsEntity {

    @Id
    @GeneratedValue
    private Long userId;

    private String userEmail;

    private String password;

    private String phoneNumber;

    @UpdateTimestamp
    private LocalDateTime lastUpdatedDate;

    @CreationTimestamp
    private LocalDateTime createdDate;

    @OneToMany(mappedBy="mappingUserDetailsEntity")
    private List<RegistrationDetails> listofSubmittedProposals=new ArrayList<>();

    //getters and setters   
}

I am getting this error on console


org.postgresql.util.PSQLException: ERROR: relation "userdetailsentity" does not exist
  Position: 15

0 个答案:

没有答案