休眠h2可嵌入列表预期的“标识符". [英] hibernate h2 embeddable list expected "identifier"
问题描述
我正在尝试在我的员工实体中关联功能列表(可嵌入的功能),H2对此表示不满,因为它希望有一个标识符"
I'm trying to associate a list of function (whom Embeddable) within my Employee Entity and H2 seems unhappy with this saying that it expected an "identifier"
由以下原因引起:org.h2.jdbc.JdbcSQLException:SQL语句中的语法错误" 创建表EMPLOYEE_FUNCTIONS( EMPLOYEE_EMPLOYEEID VARCHAR(255)非空, 活动布尔值不为NULL, DEPARTMENTNUMBER INTEGER NOT NULL, 说明VARCHAR(255), ORDER [*] INTEGER NOT NULL )";预期的标识符";
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement " CREATE TABLE EMPLOYEE_FUNCTIONS ( EMPLOYEE_EMPLOYEEID VARCHAR(255) NOT NULL, ACTIVE BOOLEAN NOT NULL, DEPARTMENTNUMBER INTEGER NOT NULL, DESCRIPTION VARCHAR(255), ORDER[*] INTEGER NOT NULL ) "; expected "identifier";
问题是我已经在另一个项目中做到了,我不明白为什么它不起作用.
The thing is I already done that with an other project and I don't see why it doesn't work.
Employee.java
Employee.java
@Entity
public class Employee extends AbstractScheduleEntity<EmployeeSchedule> {
public static final String ACOMBA_UNIQUE_FIELD = "acombaUnique";
@Id
@GenericGenerator(name = "sequence_id", strategy =
"ca.tecsar.core.sql.ServerSequenceGenerator")
@GeneratedValue(generator = "sequence_id")
@Column(name = "EmployeeID", unique = true, nullable = false)
private String employeeID;
@ElementCollection
private List<Function> functions;
//getter and setter
}
Function.java
Function.java
@Embeddable
public class Function implements Serializable {
private int order;
private boolean active;
private String description;
private int departmentNumber;
//getter and setter
}
我删除了Employee中不必要的一些属性. 可能导致此错误的原因是什么?是因为我在Employee中有一个String作为标识符吗?如果是这样,我如何告诉Hibernate添加Employee_EmployeeID作为标识符? 谢谢
I removed a few properties in Employee that wasn't necessary. What may cause this error? Is it because I have a String as identifier in my Employee? If so how can I tell to Hibernate to add Employee_EmployeeID as identifier? Thanks
推荐答案
原来我很笨,并命名为"Order"列.想知道为什么H2不开心:upside_down:
Turns out I was being dumb and named a column "Order". Wonder why H2 wasn't happy :upside_down:
将变量名更改为其他名称,然后它起作用了!
Changed the variable name to something else and it worked!
这篇关于休眠h2可嵌入列表预期的“标识符".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!