3

私はそのような問題に遭遇し、それを解決する方法がわかりません。問題は次です: 私は次のモデルを持っています:

@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で取得できます。しかし、リポジトリで次のメソッドを呼び出すとすぐに:

domain.Authority findByAuthority(enums.Authority authority);

私は次の例外を取得します:

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
4

1 に答える 1

4

select top ? ...確かに、MySQL の有効なクエリではありません。

Hibernate 構成のSQL ダイアレクト設定を確認してください。

于 2013-07-05T15:33:20.287 に答える