小编Man*_*anu的帖子

由null version_rank阻止的flyway迁移

我正在使用PostgreSQL 9.5和flyway 5.0.7

在之前的6次迁移中,一切都运行良好,但现在它已经阻止了最新的迁移

我有以下错误:

22:27:45.230 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Flyway Community Edition 5.0.7 by Boxfuse
22:27:45.408 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Database: jdbc:postgresql://localhost:32767/my_db (PostgreSQL 9.5)
22:27:45.566 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Successfully validated 7 migrations (execution time 00:00.061s)
22:27:45.658 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Current version of schema "public": 6
22:27:45.733 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Migrating schema "public" to version 7 - update
Exception in thread "main" org.flywaydb.core.internal.exception.FlywaySqlException: 
Unable to insert row for version '7' in Schema History table "public"."flyway_schema_history"
---------------------------------------------------------------------------------------------
SQL …
Run Code Online (Sandbox Code Playgroud)

flyway

8
推荐指数
2
解决办法
2041
查看次数

数组的 jOOQ 查询的奇怪翻译包含函数

我的 PostgreSQL 数据库中有以下类型:

myoptions text[]
Run Code Online (Sandbox Code Playgroud)

我使用 jOOQ 转换器,以便在我的记录中有一个 Set 作为相应类型:

Set<String> myoptions
Run Code Online (Sandbox Code Playgroud)

在我的查询中,我有以下条件:

c.MYOPTIONS.contains(Sets.newHashSet("option1"))
Run Code Online (Sandbox Code Playgroud)

在 SQL 中翻译如下:

cast("c"."myoptions" as varchar) like ('%' || '[option1]' || '%') escape '!'
Run Code Online (Sandbox Code Playgroud)

这是正常行为吗?

我想要类似的东西:

c.myoptions @> ARRAY['option1']
Run Code Online (Sandbox Code Playgroud)

或者

'option1' = ANY(c.myoptions)
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助

java sql postgresql jooq

5
推荐指数
1
解决办法
2085
查看次数

HIBERNATE - JPA2 - H2 - 按键查询@ElementCollections HashMap

我正在使用hibernate-entitymanager 3.6.4.Final和h2数据库1.3.155

我正在使用H2Dialect.

我在使用@ElementCollection中的元素过滤记录时遇到问题.这是我的实体

@Entity
public class Item {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @MapKeyColumn(name="name", length=50)
  @Column(name="value", length=100)
  protected Map<String, String> attributes;
  /*  etc.  */
}
Run Code Online (Sandbox Code Playgroud)

这是我的查询:

Item item = em.createQuery("FROM Item i JOIN i.attributes a WHERE KEY(a)='myAttrName'").getSingleResult();
Run Code Online (Sandbox Code Playgroud)

这是错误消息:

4971 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 90022, SQLState: 90022
4971 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Function "KEY" not found; SQL statement:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为函数KEY()和VALUE()在这里的doc中可用

我错过了一些配置吗?任何的想法 ?

提前致谢

filtering hibernate hashmap h2 jpa-2.0

3
推荐指数
1
解决办法
8129
查看次数

标签 统计

filtering ×1

flyway ×1

h2 ×1

hashmap ×1

hibernate ×1

java ×1

jooq ×1

jpa-2.0 ×1

postgresql ×1

sql ×1