sql语句都能写在哪些地方

时间:2021-02-03 03:28:00
mapper.xml     dao实现类     sqlDevlope图形化工具     dos命令行     
 
 
ssm框架:写到mapper.xml文件中
 
 <mapper namespace="com.xdl.dao.DeptDao">
 <select id="findAll" resultType="com.xdl.entity.Dept">
     select * from DEPT order by DEPTNO
 </select>
 
 <insert id="save" parameterType="com.xdl.entity.Dept">
 insert into DEPT (DEPTNO,DNAME,LOC)
 values (dept_seq.nextval,#{dname},#{loc})
 </insert>
 </mapper>
 
 
 
ssh框架:写到daoImpl类中
 
     @Resource
    private HibernateTemplate template;
    @Override
    public List<Dept> findAll() {
        String hql = "from Dept order by deptno";
        List list = template.find(hql);
        return list;
    }