首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Data findBy枚举

问Spring Data findBy枚举
EN

Stack Overflow用户
提问于 2013-07-05 22:39:50
回答 1查看 3.6K关注 0票数 3

我遇到过这样的问题,不知道该如何解决。问题是下一个:我有下一个模型:

代码语言:javascript
复制
@Entity(name="Authority")
@Table(name="AUTHORITIES")
public class Authority implements GrantedAuthority {

@Id
private long id;

@Enumerated(EnumType.STRING)
@Column(name="authority")
private asdevelopment.action.enums.Authority authority;

/**
 * 
 */
private static final long serialVersionUID = 1L;

@Override
public String getAuthority() {
    return authority.toString();
}

/**
 * @return the id
 */
public long getId() {
    return id;
}

}


public enum Authority {

CLIENT_ROLE, ADMIN_ROLE;

}

我可以节省权限和获得ID没有任何问题。但是当我在存储库中调用next方法时:

代码语言:javascript
复制
domain.Authority findByAuthority(enums.Authority authority);

我得到了下一个异常:

代码语言:javascript
复制
Hibernate: select top ? authority0_.id as id1_, authority0_.authority as authority1_ from AUTHORITIES authority0_ where authority0_.authority=?
13:48:01.125  WARN [main] org.hibernate.engine.jdbc.spi.SqlExceptionHelper:143 - SQL   Error: 1064, SQLState: 42000
13:48:01.125 ERROR [main] org.hibernate.engine.jdbc.spi.SqlExceptionHelper:144 - You    have an error in your SQL syntax; check the manual that corresponds to your MySQL server    version for the right syntax to use near '2 authority0_.id as id1_, authority0_.authority as authority1_ from AUTHORITIES ' at line 1
EN

回答 1

Stack Overflow用户

发布于 2013-07-05 23:33:20

对于MySQL,select top ? ...肯定不是有效的查询。

在您的Hibernate配置中检查SQL dialect setting。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17491441

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档