Well, if you can use Java 5, I'd advice you to use annotations (your #2), but you don't even need to generate XML. Look at Hibernate Annotations
http://www.hibernate.org/397.html .
Moreover, this choice is the future of o/r mapping. This is using the EJB3/JPA specification, using the completely standard annotations from the javax.persistence package (obviously Hibernate is also providing some non standards annotations if you want to do things that standard do not [yet] permit).
Even Gavin King considers annotations to be the future default way to map your beans :
http://www.javafree.org/content/view.jf?idContent=3
Quote:
In fact, I fully expect that this will be the most common way to use ORM in the future.
Your beans will look like this :
Code:
@Entity
public class Flight implements Serializable {
Long id;
@Id
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
}
http://www.hibernate.org/hib_docs/annot ... tml#d0e161