JPQLException: t.id status field path cannot be resolved to a valid type

I am using eclipseLink and have it under the specified request.

Query q = entityManager.createQuery("SELECT t FROM "
                    + clazz.getName() + " t WHERE t.id = :id");
            q.setParameter("id", id);
            matchedEntity = (T) q.getSingleResult();

However, sometimes I get the following error

java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Problem compiling [SELECT t FROM com.mt.igg.entities.CitizenRequest t WHERE t.id = :id]. 
[57, 61] The state field path 't.id' cannot be resolved to a valid type.
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at com.sun.proxy.$Proxy94.createQuery(Unknown Source)

The code works sometimes, and only sometimes I get the above error. The case of fields in the query is the same as in the object.

I am using tomcat server to deploy the project

Edit: CitizenRequest object:

@Entity
@Table(name = "CITIZEN_REQUEST")
@Multitenant
@TenantDiscriminatorColumn(name = "TENANT_ID", contextProperty = PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT)
public class CitizenRequest implements Serializable {

    // id of CitizenRequest
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private Integer id;
    // Title of CitizenRequest
    @Column(name = "TITLE_ID")
    @NotNull
    private Integer title;
+4
source share

Source: https://habr.com/ru/post/1542026/


All Articles