1

I am using spring data Jpa and i want to map one table called Client with my class called ClientList and am getting error saying client is not mapped [SELECT c FROM client c] in named query.here is the below code

here is my entity class and getting error saying HHH000177: Error in named query: getAllClients org.hibernate.hql.internal.ast.QuerySyntaxException: client is not mapped [SELECT c FROM client c]

package com.abc.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@NamedQueries({
    @NamedQuery( name="getAllClients" , query="SELECT c FROM client c")
  })

@Entity
@Table(name="client")
public class ClientList {


@Id
@Column(name="ClientName")
 String clientName;

@Column(name="ClientId")
 String clientId;

@Column(name="ImplementationCode")
String implementationCode;

@Column(name="createddate")
String cretedDate;

public String getClientName() {
    return clientName;
}

public void setClientName(String clientName) {
    this.clientName = clientName;
}



public String getClientId() {
    return clientId;
}

public void setClientId(String clientId) {
    this.clientId = clientId;
}

public String getImplementationCode() {
    return implementationCode;
}

public void setImplementationCode(String implementationCode) {
    this.implementationCode = implementationCode;
}

public String getCretedDate() {
    return cretedDate;
}

public void setCretedDate(String cretedDate) {
    this.cretedDate = cretedDate;
}

@Override
public String toString() {
    return "ClientDetails [clientName=" + clientName + ", clientId=" + clientId + ", implementationCode="
            + implementationCode + ", cretedDate=" + cretedDate + "]";
}

public ClientList(String clientName, String clientId, String implementationCode, String cretedDate) {
    super();
    this.clientName = clientName;
    this.clientId = clientId;
    this.implementationCode = implementationCode;
    this.cretedDate = cretedDate;
}


@Id
@Column(name="ClientName")
 String clientName;

@Column(name="ClientId")
 String clientId;

@Column(name="ImplementationCode")
String implementationCode;

@Column(name="createddate")
String cretedDate;

public String getClientName() {
    return clientName;
}

public void setClientName(String clientName) {
    this.clientName = clientName;
}



public String getClientId() {
    return clientId;
}

public void setClientId(String clientId) {
    this.clientId = clientId;
}

public String getImplementationCode() {
    return implementationCode;
}

public void setImplementationCode(String implementationCode) {
    this.implementationCode = implementationCode;
}

public String getCretedDate() {
    return cretedDate;
}

public void setCretedDate(String cretedDate) {
    this.cretedDate = cretedDate;
}

@Override
public String toString() {
    return "ClientDetails [clientName=" + clientName + ", clientId=" + clientId + ", implementationCode="
            + implementationCode + ", cretedDate=" + cretedDate + "]";
}

public ClientList(String clientName, String clientId, String implementationCode, String cretedDate) {
    super();
    this.clientName = clientName;
    this.clientId = clientId;
    this.implementationCode = implementationCode;
    this.cretedDate = cretedDate;
}


@Id
@Column(name="ClientName")
 String clientName;

@Column(name="ClientId")
 String clientId;

@Column(name="ImplementationCode")
String implementationCode;

@Column(name="createddate")
String cretedDate;

public String getClientName() {
    return clientName;
}

public void setClientName(String clientName) {
    this.clientName = clientName;
}



public String getClientId() {
    return clientId;
}

public void setClientId(String clientId) {
    this.clientId = clientId;
}

public String getImplementationCode() {
    return implementationCode;
}

public void setImplementationCode(String implementationCode) {
    this.implementationCode = implementationCode;
}

public String getCretedDate() {
    return cretedDate;
}

public void setCretedDate(String cretedDate) {
    this.cretedDate = cretedDate;
}

@Override
public String toString() {
    return "ClientDetails [clientName=" + clientName + ", clientId=" + clientId + ", implementationCode="
            + implementationCode + ", cretedDate=" + cretedDate + "]";
}

public ClientList(String clientName, String clientId, String implementationCode, String cretedDate) {
    super();
    this.clientName = clientName;
    this.clientId = clientId;
    this.implementationCode = implementationCode;
    this.cretedDate = cretedDate;
 }
}
shridhar
  • 79
  • 1
  • 12

2 Answers2

2

Your entity name is ClientList so you query should be select c from ClientList c.

talex
  • 17,973
  • 3
  • 29
  • 66
0

Since you are not defining the NamedQuery as native, you need to use the names [for tables and columns] as defined by the java classes, and not as defined by your JPA annotations.

In your example, use "ClientList" as table name in your Named Query definition.