简体   繁体   中英

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 3.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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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