CriteriaBuilder criteriaBuilder=this.baseDao.getEntityManager().getCriteriaBuilder();
CriteriaQuery<OperationLog> criteriaQuery= criteriaBuilder.createQuery(OperationLog.class);
Root<OperationLog> root=criteriaQuery.from(OperationLog.class);
Predicate predicate = criteriaBuilder.equal(root.get("userId"), "7965554cd09841ee9d864845178b9cd10");
criteriaQuery.select(root);
Query query=this.baseDao.getEntityManager().createQuery(criteriaQuery);
//Query query1=this.baseDao.getEntityManager().createNativeQuery();
List<OperationLog> operationLogs=query .getResultList();
QOperationLog operationLog= QOperationLog.operationLog;
JPAQuery<OperationLog> jpaQuery=new JPAQuery<>(this.baseDao.getEntityManager());
jpaQuery.from(operationLog).select(operationLog).where();
List<OperationLog> operationLogList= jpaQuery.fetch();
JPAQueryFactory jpaQueryFactory=new JPAQueryFactory(this.baseDao.getEntityManager());
long count= jpaQueryFactory.delete(operationLog).where(operationLog.userId.eq("7965554cd09841ee9d864845178b9cd10")).execute();
JPA 操作EntityManager
最新推荐文章于 2023-05-22 20:13:33 发布