我正在使用Spring JPA 1.7和QueryDSL 3.5.1。我收到'找不到财产'错误。 这是我的课程。
@Entity
@Table(name="Device")
public class Device implements Serializable {
private static final long serialVersionUID = 1L;
@NotEmpty
@Id
@Column(name="deviceId")
private String deviceId="";
@Column(name="accountId")
private String accountId="";
@Column(name="groupId")
private String groupId="";
@Column(name="equipmentType")
private String equipmentType="";
@Column(name="deviceCode")
private String deviceCode="";
@Column(name="deviceType")
private String deviceType="";
@NotEmpty
@Column(name="simId")
private String simId="";
@NotEmpty
@Column(name="imeiNumber")
private String imeiNumber="";
@Column(name="simPhoneNumber")
private String simPhoneNumber="";
@Column(name="driverId")
private String driverId="";
@Column(name="pushpinId")
private String pushpinId=""; //who registered device? JMA/MDM/JAMS
@Column(name="isActive", columnDefinition="INT(1)")
private boolean isActive = false;
@Column(name="displayName")
private String displayName="";
@Column(name="description")
private String description="";
@Column(name="notes")
private String notes="";
@Column
@JsonSerialize(using=DateSerializer.class)
private long creationTime;
@Column
@JsonSerialize(using=DateSerializer.class)
private long lastUpdateTime;
//Getters and setters
}
public interface DeviceRepository extends PagingAndSortingRepository<Device, String>, DeviceRepositoryCustom {
public Page<Device> findAll(com.mysema.query.types.Predicate predicate, Pageable pageable);
}
public interface DeviceRepositoryCustom {
public List<Device> selectByEquipmentTypeAndAnyColumnLike(String equipmentType, String creationTime, String searchField, String searchText, boolean hasPushId);
}
public class MdmPredicates {
public static com.mysema.query.types.Predicate anyFieldLike(String field, String text) {
QDevice device = QDevice.device;
//Do something later
return device.deviceId.contains(text);
}
}
Here is the error log:
aused by: org.springframework.data.mapping.PropertyReferenceException: No property find found for type entities.Device
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:72)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:188)
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:277)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:257)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:68)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:57)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:290)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:158)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:162)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:44)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
我知道当我不使用真实列名而不是属性名时会发生错误。但是类中的属性名称与列名称都相同。
请你告诉我我错过了什么? 感谢您的帮助。