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

ParserException: ERROR. pos 198, line 1, column 197, token DOT #2416

Closed
ruanxuefeng opened this issue Feb 14, 2019 · 1 comment
Closed

ParserException: ERROR. pos 198, line 1, column 197, token DOT #2416

ruanxuefeng opened this issue Feb 14, 2019 · 1 comment
Labels

Comments

@ruanxuefeng
Copy link

ruanxuefeng commented Feb 14, 2019

AdminUser.java

@Table(name = "admin_user")
@Entity
@EqualsAndHashCode(exclude = {"id"})
@Data
public class AdminUser implements BaseEntity {
    @javax.persistence.Id
    @Column(length = 18)
    private Long id;

    @Column(length = 18,updatable = false)
    private Long creator;

    @Column(name = "create_time",updatable = false)
    private LocalDateTime createTime;

    @Column(length = 64)
    private String email;

    @Column(length = 512)
    private String avatar;

    @Column(length = 128)
    private String name;

    @Enumerated(EnumType.ORDINAL)
    private Gender gender;

    @ManyToMany(fetch = FetchType.EAGER)
    @OrderBy("id desc")
    @JoinTable(name = "user_role",joinColumns = @JoinColumn(name = "user"), inverseJoinColumns = 
    @JoinColumn(name = "role"))
    private List<Role> roleList;

}

Role.java

@EqualsAndHashCode()
@Entity
@Table(name = "role")
@Data
public class Role implements BaseEntity {

    @javax.persistence.Id
    private Long id;

    @Column(updatable = false)
    private Long creator;

    @Column(length = 32)
    private String name;

    @Column(length = 256, name = "`describe`")
    private String describe;

    @Column(updatable = false)
    private LocalDateTime createTime;
}
JPAQueryFactory queryFactory = new JPAQueryFactory(entityManager);
        QAdminUser qAdminUser = QAdminUser.adminUser;
        QAdminUser creator = new QAdminUser("creator");

        JPAQuery<AdminUser> query = queryFactory.select(
                Projections.bean(
                        AdminUser.class,
                        qAdminUser.id,
                        qAdminUser.name,
                        qAdminUser.email,
                        qAdminUser.avatar,
                        qAdminUser.gender,
                        qAdminUser.createTime,
                        qAdminUser.roleList,
                        creator.name.as("userName")
                )
        )
                .from(qAdminUser)
                .leftJoin(creator).on(qAdminUser.creator.eq(creator.id))
                .offset(page.getCol())
                .limit(page.getPageSize())
                .orderBy(qAdminUser.id.desc())
                .fetch();

Generated sql

SELECT
	adminuser0_.id AS col_0_0_,
	adminuser0_.NAME AS col_1_0_,
	adminuser0_.email AS col_2_0_,
	adminuser0_.avatar AS col_3_0_,
	adminuser0_.gender AS col_4_0_,
	adminuser0_.create_time AS col_5_0_,

         /**↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓**/
	.AS col_6_0_,
        /**↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑**/

	adminuser1_.NAME AS col_7_0_,
	role3_.id AS id1_3_,
	role3_.create_time AS create_t2_3_,
	role3_.creator AS creator3_3_,
	role3_.`describe` AS describe4_3_,
	role3_.NAME AS name5_3_ 
FROM
	admin_user adminuser0_
	INNER JOIN user_role rolelist2_ ON adminuser0_.id = rolelist2_.
	USER INNER JOIN role role3_ ON rolelist2_.role = role3_.id
	LEFT OUTER JOIN admin_user adminuser1_ ON ( adminuser0_.creator = adminuser1_.id ) 
ORDER BY
	adminuser0_.id DESC 
	LIMIT ?

query add qAdminUser.roleList,it can't work
but remove qAdminUser.roleList,it can work

@stale
Copy link

stale bot commented Jun 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 3, 2021
@stale stale bot closed this as completed Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant