Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加别名 #245

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

添加别名 #245

wants to merge 5 commits into from

Conversation

tjpanda88
Copy link

@tjpanda88 tjpanda88 commented Mar 23, 2018

@column的字段名含名表别名的时候,会出现检索不到值的问题。
经过调查原因是SQL的返回字段名和ResultMap中的字段名不匹配造成的。
SQL的返回字段名只含有字段名(不含名表别名),ResultMap中的字段名是和@column的name属性一致的(含名表别名)。

出现问题的代码如下:
我的代码是通过在表名中加入Left Join以实现简单的多表关联查询。但是就算没有多表查询,@column中指定表别名的时候依旧会有问题的。

@Table(name = 
             "ATABLE AS A " + 
             "LEFT JOIN BTABLE AS B ON A.id = B.id "
)
public class AlipayComposite {

    @Id
    @Column(name = "A.field1")
    private Long atableField1;

    @Column(name = "BTable.field1")
    private String btableField1;

    // ....Get/Set略	
}

@abel533
Copy link
Owner

abel533 commented Oct 16, 2022

这种改动相当于不使用resultMap了...特殊情况先不考虑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants