QueryDSL JPASQLQuery内部连接错误

时间:2015-03-01 10:06:16

标签: java jpa querydsl

我正在尝试将以下jpa查询转换为QueryDSL。

select 
    NEW aaa.dto.UserDto(s.username, i.mailaddress, s.enabled, i.lastlogin, i.lastlogout, i.loginErrorcount) 
from 
    SUsers s, UserInfo i 
where 
     s.username = i.username

查询dsl测试代码如下。

@Test
public void test3() throws Exception {
    JPASQLQuery query = new JPASQLQuery(em, new H2Templates());
    QSUsers qsUser = QSUsers.sUsers;
    QUserInfo qInfo = QUserInfo.userInfo;
    List<UserDto> dtos = query.from(qsUser, qInfo).where(qsUser.username.eq(qInfo.username))
            .list(ConstructorExpression.create(UserDto.class, qsUser.username, qInfo.mailaddress, qsUser.enabled, qInfo.lastlogin, qInfo.lastlogout, qInfo.loginErrorcount));
    assertThat(dtos.size(), not(0));
}

然后发生了以下错误。

  

SQL错误:42001,SQLState:42001       “SELECT SUSERS.USERNAME,USERINFO.MAILADDRESS,SUSERS.ENABLED,USERINFO.LASTLOGIN,USERINFO.LASTLOGOUT,USERINFO.LOGINERRORCOUNT       来自USERS SUSERS,USERINFO       WHERE SUSERS.USERNAME = USERINFO。 “;期望”标识符“; SQL语句:

我不确定为什么缺少右侧identifire

0 个答案:

没有答案