现在是否需要具有POJO=>实体映射(存在问题),然后再进行第二个实体=>DB表映射(JPA注释)?我发现只使用Entity类作为我的主要java对象并在必要时持久化它们更容易,毕竟Entity类本质上是带有几个JPA注释的POJO。
此外,在确实需要保持分离的情况下,执行POJO=>实体映射的最佳位置是什么,目前我在CRUD方法中执行此操作,例如:
public void addCustomerPOJO(Customer customerPOJO){
//Cteat EntityManager and start a Transaction
//Create Entity class and populate it with values
//from the passed-in regular (non entity) Customer class
//Persiste and close
}
有没有更好的或更常见的方法来做这个?