似乎在我看来,到处都有过时的版本,不再起作用。
我的问题看起来很简单。我有一个 Java 类,它映射到 derby 数据库。我正在使用注释,并成功地在数据库中创建了所有其他表,但在这个特定的示例中,我只需要一个 Map,它不使用任何其他类,只需要两个简单的字符串值。我在尝试网上找到的所有内容时遇到了各种类型的错误。
有人知道在不使用已弃用的注释的情况下执行此操作的简单方法吗?
提前致谢!
第2.2.5.3.4章 http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html#entity-mapping-associationHibernate Annotations 文档描述了必要的注释。你需要做类似的事情:
@Entity
public class MyEntity {
...
@ElementCollection // this is a collection of primitives
@MapKeyColumn(name="key") // column name for map "key"
@Column(name="value") // column name for map "value"
public Map<String,String> getMyMap() {
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)