hibernate不会创建表
*我在实体中得到了以下内容。
@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
//Trind
*I got the following in an entity.
@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;
}
}
i get the following error
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))
Anyone got any idea how i should do so is properties_KEY is not null instead?
I use Hibernate Hibernate 3.6.5.Final, MSSQL
//Trind
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎正在使用 hashmap 映射值类型的集合。你必须使用
@MapKeyColumn
指定 hashmap 的键列,例如,你可以尝试一下是否可以解决问题:
It seems that you are mapping the collection of the value type using the hashmap . You have to specify the key column of the hashmap using
@MapKeyColumn
For example , you can try it to see if the problem can be solved:
我相信你可以做这样的事情:
I belive you can do something like this: