在調(diào)用 Account.dao.findAll () 時(shí)報(bào)如下錯(cuò)誤。 execute error. SELECT * FROM sso_userorg.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"采用的驅(qū)動(dòng)為<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.4-1202-jdbc4</version> </dependency>Account 類(lèi)如下: /** * 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貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊
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貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊
@Table(xxx,generatedKey="")如果沒(méi)有自增并且是自己手動(dòng)set值,把自增主鍵設(shè)置為空,其實(shí)@Table 里已經(jīng)設(shè)計(jì)了 代碼級(jí)的主鍵生成策略,你可以自實(shí)現(xiàn) Generator,不用每次都自己手動(dòng)set進(jìn)去,@Table(xxx,generatedKey="id",generator=xx.class,generated=true) 使用generator來(lái)生成主鍵
添加回答
舉報(bào)
0/150
提交
取消