package com.nationalelectric.greenH5.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.stereotype.Service; import com.nationalelectric.greenH5.po.GreenEAccount; import com.sgcc.uap.persistence.IHibernateDao; @Service public class EAccountService { @Autowired private IHibernateDao hibernateDao; public GreenEAccount getOne(String userId) { String sql = "select * from green_e_account where user_id = ? "; List list = hibernateDao.queryForListWithSql(sql, new Object[]{userId}, new BeanPropertyRowMapper(GreenEAccount.class)); if (list.size() == 1) { System.out.println(list.get(0)); return list.get(0); } else if (list.size() > 1){ System.out.println("error: ---------EAccount 表 获取到多记录-------!!!!!"); } return null; } public GreenEAccount getById(Long id) { String sql = "select * from green_e_account where id = ? "; List list = hibernateDao.queryForListWithSql(sql, new Object[]{id}, new BeanPropertyRowMapper(GreenEAccount.class)); if (list.size() == 1) { System.out.println(list.get(0)); return list.get(0); } else if (list.size() > 1){ System.out.println("error: ---------EAccount 表 获取到多记录-------!!!!!"); } return null; } // 添加或修改 public void saveOrUpdate(GreenEAccount eAccount) { hibernateDao.saveOrUpdateObject(eAccount); System.out.println("---ok-----"); } }