3

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

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I want to specifically 'Annotize' a class to match the first two answers in the question.
0

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,

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.