我正在尝试执行查询,这在JPA中运行正常,但这些不适用于Open JPA,您有什么想法吗?
String iNString;
try {
String query = "Delete FROM Table1o WHERE o.Pk1 IN('"+ iNString+ "') and o.countryCode = '"+ countryCode+ "'";
entityManager().createQuery(query).executeUpdate();
LOGGER.info("Delete Query-----------------: " + query);
}
catch( Exception exception ) {
throw new DataLayerException(exception.getMessage(),exception);
}
错误:-org.springframework.dao.InvalidDataAccessApiUsageException:没有 找到类型为“class java.lang.String”的元数据。班级不是 增强;嵌套异常是org.apache.openjpa.persistence.ArgumentException:否 找到类型为“class java.lang.String”的元数据。班级不是 增强。
答案 0 :(得分:0)
EntityManager em = Relationship.entityManager(); StringBuilder sbQueryString = new StringBuilder(" SELECT o FROM table AS o WHERE 1 = 1"); if(StringUtils.isNotEmpty(DTO.getNameEng())){ sbQueryString.append(" AND LOWER(o.NameEng)LIKE:_NAME_ENG"); }
sbQueryString.append(" order by o.relationshipNameEng");
TypedQuery<Relationship> q = em.createQuery(sbQueryString.toString(), User.class);
if (StringUtils.isNotEmpty(DTO.getRelationshipNameEng())) {
q.setParameter("_NAME_ENG", "%" + DTO.getNameEng().toLowerCase() + "%");
}