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
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Integer id;
@Column(name = "TITLE_ID")
@NotNull
private Integer title;
source
share