使用 jpa 映射 Hibernate 标记接口
您好,我是休眠新手,在映射标记接口方面面临问题。 我有一个标记界面。
public interface Item{}
然后有两个类实现这个接口:
public class Hotel implements Item{
private int id;
private String name;
private String location;
.......
}
public class Restaurant implements Item{
private int id;
private String name;
private String cuisine;
.......
}
还有另一个类使用这两个类:
public class ItineraryItem {
private int id;
private Item item;
}
如何使用注释映射这些类。
Hi I am new to hibernate and am facing problem in mapping marker interface.
I have a marker interface.
public interface Item{}
Then there are two classes which implement this interface:
public class Hotel implements Item{
private int id;
private String name;
private String location;
.......
}
public class Restaurant implements Item{
private int id;
private String name;
private String cuisine;
.......
}
There is another class which uses these two classes:
public class ItineraryItem {
private int id;
private Item item;
}
How can I map these classes using annotations.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码:
InheritanceType.TABLE_PER_CLASS
将导致Hotel
和Restaurant
拥有自己单独的表。您可以在这里找到更多信息:http://en.wikibooks.org/wiki/Java_Persistence/Inheritance< /a>
Code:
InheritanceType.TABLE_PER_CLASS
will causeHotel
andRestaurant
to have their own separate tables.You can find more information here: http://en.wikibooks.org/wiki/Java_Persistence/Inheritance