mybatis中外键查询,外键表中又有外键

mybatis中,一张表有两个外键,怎么查另外两张表的内容?而这两张表又有外键(一张表一个,一张表两个),该怎么查











<association property="cp" javaType="CpTO">  
    <id column="CP_ID" property="id"/>
    <result column="CNAME" property="name"/>
    <result column="MY_CONTACTOR" property="myContactor"/>
    <result column="CONTACTOR_EMAIL" property="contactorEmail"/>
</association>

<association property="appCategory" javaType="AppCategoryTO">  
    <id column="APP_CATEGORY_ID" property="id"/> 
    <result column="ACNAME" property="name"/>  
</association>


配置的时候就像这样,association中的就是外键对应的对象,外键中有外键就继续嵌套

是要怎么写sql语句吧??

select * from user_constraints cc where cc.r_constraint_name in (
select c.r_constraint_name
from user_constraints c
where c.constraint_type = 'R'
and c.constraint_name = '??' )

?? 是你外键的名字;spiderrobot 的方法也不错,但是当前用户要有 dba 权限; user_constraints 只能查当前用户的对象
这是我看别人回答的,希望对你有用

我现在做的项目中数据库中没有定义外键约束,都是通过程序来实现;
如果查询A实体同时需要B或和C实体的属性,那就把需要的属性都添加到A实体中,mapperxml中ResultMap中添加对应的属性,
SQL语句中使用Join查询,返回对应的列就好。