*我在实体中得到了以下内容。
@Entity("User")
public class User implements java.io.Serializable {
@ElementCollection(fetch=FetchType.EAGER)
@CollectionTable(name="FrameworkUser_Properties")
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
}
我收到以下错误
Unsuccessful: create table FrameworkUser_Properties (User_id int not null, properties varchar(255) null, properties_KEY varchar(255) null, primary key (User_id, properties_KEY))
有人知道我应该怎么做吗,properties_KEY 不为空吗? 我使用Hibernate Hibernate 3.6.5.Final,MSSQL
//特林德
最佳答案
您似乎正在使用 hashmap 映射值类型的集合。您必须使用 @MapKeyColumn
例如,您可以尝试一下是否可以解决问题:
@ElementCollection(fetch=FetchType.EAGER)
@CollectionTable(name="FrameworkUser_Properties")
@MapKeyColumn
public Map<String, String> getProperties() {
return properties;
}
关于java - hibernate不会创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6647016/