使用postgresql时报的异常

龙影 发布于 2015/09/06 17:41
阅读 3K+
收藏 0

@Dreampie 你好,想跟你请教个问题:

在调用Account.dao.findAll()时报如下错误。

execute error. SELECT * FROM sso_user
org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"

采用的驱动为

<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.4-1202-jdbc4</version> </dependency>

Account类如下:

/**  * Created by loyin on 15/9/6.  */ @Table(name="sso_user") public class Account extends Model<Account> { public static Account dao=new Account();
}

换了好几个版本的驱动都是报同样的问题。请帮忙解决下。

加载中
0
Dreampie
Dreampie

Whe using PostgreSQL, all SELECT statements will fail with message: org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"

Seems to be related to this issue

This has been fixed with version 1.1.2.

The fix requires the QuirkMode enum flag to be set to PostgreSQL when creating a new instance of sql2o. It changes default behaviour of queries to NOT fetch generated keys by default. When it is needed to fetch generated keys, the returnGeneratedKeys parameter in the generateQuery method should be set.



http://stackoverflow.com/questions/24636120/postgres-jdbc-driver-psqlexception-syntax-error-at-or-near-returning 看看是不是这个

0
Dreampie
Dreampie

表有自增主键吗,用github上最新的代码试试,如果还有问题 @ 我

0
龙影
龙影
@Dreampie 表没有自增主键。采用自定义的主键生成机制。
0
Dreampie
Dreampie

那你用github上最新代码   @Table(xxx,generatedKey="")如果没有自增并且是自己手动set值,把自增主键设置为空,其实@Table 里已经设计了 代码级的主键生成策略,你可以自实现  Generator,不用每次都自己手动set进去,@Table(xxx,generatedKey="id",generator=xx.class,generated=true)  使用generator来生成主键

返回顶部
顶部