在调用 Account.dao.findAll () 时报如下错误。 execute error. SELECT * FROM sso_userorg.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();
}
2 回答
拉莫斯之舞
TA贡献1820条经验 获得超10个赞
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.
慕村9548890
TA贡献1884条经验 获得超4个赞
@Table(xxx,generatedKey="")如果没有自增并且是自己手动set值,把自增主键设置为空,其实@Table 里已经设计了 代码级的主键生成策略,你可以自实现 Generator,不用每次都自己手动set进去,@Table(xxx,generatedKey="id",generator=xx.class,generated=true) 使用generator来生成主键
添加回答
举报
0/150
提交
取消