简体   繁体   English

使用注释的Hibernate视图

[英]Hibernate Views using Annotations

Learned that it is possible to write a SELECT where each row can be effectively mapped to an object: 了解到可以编写一个SELECT ,其中每行可以有效地映射到一个对象:

Elegant ways to handle database views on hibernate entities? 在hibernate实体上处理数据库视图的优雅方法?

However, all answers use XML. 但是,所有答案都使用XML。

How is this done using Annotations? 如何使用Annotations完成?

I am using Hibernate 3.3.1 GA & Hibernate Annotations 3.4 GA which are a part of JBoss 5.1 for JDK6 我正在使用Hibernate 3.3.1 GAHibernate Annotations 3.4 GA ,这是JBoss 5.1 for JDK6的一部分

You can definitely use Annotations to map Objects to Tables. 您绝对可以使用Annotations将对象映射到表。 Essentially you need to use JPA (Java Persistence Annotation), there are also some Hibernate specific annotations that you could use. 基本上你需要使用JPA(Java Persistence Annotation),你也可以使用一些Hibernate特定的注释。

In short, an Object representing a Table should be marked with @Entity annotation. 简而言之,表示表的Object应使用@Entity注释进行标记。 There are bunch of other annotations / attributes that you need to know to make things work 您需要知道许多其他注释/属性才能使事情有效

http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity

I think you might want to use Mapping secondary tables from the hibernate documentation. 我想您可能希望使用hibernate文档中的Mapping辅助表
It appears that you can join data from multiple tables into a single shared entity bean, 您似乎可以将多个表中的数据连接到一个共享实体bean中,

It seems that you cannot use annotation for that so far. 到目前为止,您似乎无法使用注释。 Auxiliary database objects are not covered by annotations (in Hibernate 3.6): Hibernate 3.6 Docs 注释不包括辅助数据库对象(在Hibernate 3.6中): Hibernate 3.6 Docs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM