Hibernate Views using Annotations
Learned that it is possible to write a SELECT
where each row can be effectively mapped to an object:
Elegant ways to handle database views on hibernate entities?
However, all answers use XML.
How is this done using Annotations?
I am using Hibernate 开发者_StackOverflow3.3.1 GA
& Hibernate Annotations 3.4 GA
which are a part of JBoss 5.1
for JDK6
You can definitely use Annotations to map Objects to Tables. Essentially you need to use JPA (Java Persistence Annotation), there are also some Hibernate specific annotations that you could use.
In short, an Object representing a Table should be marked with @Entity annotation. 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
I think you might want to use Mapping secondary tables from the hibernate documentation.
It appears that you can join data from multiple tables into a single shared entity 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
精彩评论