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

在调用 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();
}


qq_遁去的一_1
浏览 123回答 2
2回答

拉莫斯之舞

Whe&nbsp;using&nbsp;PostgreSQL,&nbsp;all&nbsp;SELECT&nbsp;statements&nbsp;will&nbsp;fail&nbsp;with&nbsp;message:&nbsp;org.postgresql.util.PSQLException:&nbsp;ERROR:&nbsp;syntax&nbsp;error&nbsp;at&nbsp;or&nbsp;near&nbsp;"RETURNING" Seems&nbsp;to&nbsp;be&nbsp;related&nbsp;to&nbsp;this&nbsp;issue This&nbsp;has&nbsp;been&nbsp;fixed&nbsp;with&nbsp;version&nbsp;1.1.2. The&nbsp;fix&nbsp;requires&nbsp;the&nbsp;QuirkMode&nbsp;enum&nbsp;flag&nbsp;to&nbsp;be&nbsp;set&nbsp;to&nbsp;PostgreSQL&nbsp;when&nbsp;creating&nbsp;a&nbsp;new&nbsp;instance&nbsp;of&nbsp;sql2o.&nbsp;It&nbsp;changes&nbsp;default&nbsp;behaviour&nbsp;of&nbsp;queries&nbsp;to&nbsp;NOT&nbsp;fetch&nbsp;generated&nbsp;keys&nbsp;by&nbsp;default.&nbsp;When&nbsp;it&nbsp;is&nbsp;needed&nbsp;to&nbsp;fetch&nbsp;generated&nbsp;keys,&nbsp;the&nbsp;returnGeneratedKeys&nbsp;parameter&nbsp;in&nbsp;the&nbsp;generateQuery&nbsp;method&nbsp;should&nbsp;be&nbsp;set.

慕村9548890

@Table(xxx,generatedKey="")如果没有自增并且是自己手动set值,把自增主键设置为空,其实@Table&nbsp;里已经设计了 代码级的主键生成策略,你可以自实现 &nbsp;Generator,不用每次都自己手动set进去,@Table(xxx,generatedKey="id",generator=xx.class,generated=true) &nbsp;使用generator来生成主键
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL