mybatis用association指定外键结合select实现级联属性查询

package com.gewb.dao;
import java.util.List;
import com.gewb.entity.Student;

public interface StudentDao {
public void addStudent(Student student);
// public List findStudentByAddress(int addressId);
public List findStudentWithAddress(int id);

}



package com.gewb.dao;
import com.gewb.entity.Address;

public interface AddressDao {
public Address findById(int id);

}



StudentMapper.xml

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">












insert into student values(null,#{name},#{age});



AddressMapper.xml

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">










你可能感兴趣的:(myBatis)