我在 Grails/PostgreSql 应用程序中有 POJO 域类,我正在尝试为它的 ID 映射 postgres 序列生成器。
在 POJO 中:
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "flight_id")
public long getId() {
return id;
}
在 Postgres 中:
-- Sequence: flight_id
-- DROP SEQUENCE flight_id;
CREATE SEQUENCE flight_id
INCREMENT 1
MINVALUE 1n
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE flight_id
OWNER TO postgres;
当我尝试为该域运行 grails generate-all 时,我得到:
Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown Id.generator: flight_id
除了这个,其他一切似乎都正常。我正在尝试使用 Postres 本机生成器,因此我可以选择对独立于 Grails 应用程序的数据库运行 CRUD 操作。
任何提示将不胜感激。