【发布时间】:2009-10-29 16:24:46
【问题描述】:
使用自动更新 (hibernate.hbm2ddl.auto=update) 我有一个实体,它应该创建两个表: myentity 和 myentityconfiguration 属性。 这在 Mysql 5 中运行良好,但在 SQL Server 2005 中它不会创建属性表。
有人知道吗?我没有尝试自己创建表,我想避免这种情况,所以我不知道它是否在 SQL server 中工作,但它在 Mysql 中工作正常。
这是实体(简化):
@Entity
public class MyEntity {
Map<String, String> configurations = new HashMap<String, String>();
long id = -1;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@CollectionOfElements(fetch = FetchType.EAGER)
@JoinTable(
name = "myentityconfigurationProperties",
joinColumns = @JoinColumn(name = "id")
)
@org.hibernate.annotations.MapKey(
columns = @Column(name = "propertyKey")
)
@Column(name = "propertyValue", nullable = false)
@Cascade(value = org.hibernate.annotations.CascadeType.ALL)
public Map<String, String> getConfigurations() {
return configurations;
}
public void setConfigurations(Map<String, String> configurations) {
this.configurations = configurations;
}
}
【问题讨论】:
标签: java mysql sql-server-2005 hibernate jpa