【实例简介】java web小例子
【实例截图】
【核心代码】
package wlj.daoImpl;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import wlj.common.CreateUUID;
import wlj.dao.CustomerDao;
import wlj.data.CustomerData;
import wlj.entity.Customer;
@Transactional
@Repository
public class CustomerDaoImpl implements CustomerDao {
@PersistenceContext
EntityManager em;
private static Logger loger = Logger.getLogger(CustomerDaoImpl.class);
public CustomerData saveCustomer(CustomerData cd) {
try {
Customer c = new Customer();
c.setData(cd);
String userID = CreateUUID.createUUID();
c.setId(userID);
em.persist(c);
cd.setEntity(c);
return cd;
} catch (Exception e) {
loger.debug("保存用户出错................................" e "...................................");
return null;
}
}
}