diff --git a/src/guide/ormusagetips.md b/src/guide/ormusagetips.md index 4a4a3857a9c2aa0e9e2c7f0f745bab703cbb5a86..c5b7f8b9a5e0e33daa57d2e22b2b9fb24071a9b6 100644 --- a/src/guide/ormusagetips.md +++ b/src/guide/ormusagetips.md @@ -46,13 +46,30 @@ protected EntityManager entityManager; com.warm.flow.orm.entity.FlowUser ``` -#### 使用示例 +### 以下为主要接口示例,更多接口请参考 EntityManager 接口 ```java @PersistenceContext(unitName = "warm-flow-jpa") protected EntityManager entityManager; -entityManager.find +FlowDefinition entity = dao.newEntity(); +// entity 字段填充 +// 持久化保存数据 +entityManager.persist(entity); + +// 通过主键查找数据 +FlowDefinition existEntity = entityManager.find(FlowDefinition.class, 1l); + +// 复杂查询语句通过 CriteriaQuery criteriaQuery +CriteriaQuery criteriaQuery = ... +// select语句获取结果 +entityManager.createQuery(criteriaQuery).getResultList(); + +// 更新操作使用 CriteriaUpdate criteriaUpdate +CriteriaUpdate criteriaUpdate = ... +entityManager.createQuery(criteriaUpdate).executeUpdate() ``` +### **JPA注意事项** JPA涉及持久化操作必须开启事务  @Transactional(spring) @Tran(solon) + ## mybatis-flex