在使用时创建表时,sql语句中出现语法错误 list-array
类型。
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "create table vehicle (id serial not null, vehicle_types varchar[[*]] primary key (id))"; expected "(, FOR, UNSIGNED, INVISIBLE, VISIBLE, NOT, NULL, AS, DEFAULT, GENERATED, ON, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"; SQL statement:
create table vehicle (id serial not null, vehicle_types varchar[], primary key (id)) [42001-199]
我的表定义如下所示。
import com.vladmihalcea.hibernate.type.array.ListArrayType;
@Entity
@Table(name = "vehicle")
@EqualsAndHashCode(of = {"id", "created"})
@Getter
@Setter
@TypeDef(
name = "list-array",
typeClass = ListArrayType.class
)
public class Vehicle {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonIgnore
private Integer id;
@Type(type = "list-array")
@Column(
name = "vehicle_types",
columnDefinition = "varchar[]"
)
private List<String> vehicleTypes;
}
我有以下依赖性
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<version>2.10.0</version>
</dependency>
我错过了什么?。
1条答案
按热度按时间suzh9iv81#
修好了。
改变
columnDefinition
至array
从varchar[]
```@Type(type = "list-array")
@Column(
name = "vehicle_types",
columnDefinition = "array"
)
private List vehicleTypes;