[Prev] Thread [Next]  |  [Prev] Date [Next]

[hibernate-announce] New to Hibernate Thomas Walland Wed Nov 15 18:08:07 2006


I am new to hibernate and I wanted to try out this way of java

I downloaded hibernate 3 and the hibernate annotation libraries.

I made a little project in which i want to select * from a database.
When I realize this in "the old-way" with hibernate mapping files, it
workes fine.

But when I applay the Version with Java-Annotations, I always get an
error message, which says, that my bean is not mapped or something in
this way. If I comment out the line with the query, everthing works
fine. So the set up seems to be ok. But the query doesn't work.

Here is my Annotated class:

package hibernate;

import javax.persistence.*;
import java.io.Serializable;

@Table (name="testtable")
public class ExampleDAO implements Serializable {

    public int id;

    public String name;

    public int getId() {
        return id;

    public void setId(int id) {
        this.id = id;

    public String getName() {
        return name;

    public void setName(String name) {
        this.name = name;


and here is the query-code:

AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.configure( "../../etc/conf/hibernate.cfg.xml" );
SessionFactory sf = cfg.buildSessionFactory();
Session s = sf.openSession();
Transaction tx = s.beginTransaction();
Query q = s.createQuery( "from ExampleDAO" ); << Expection

I hope i expressed my problem clearly.


hibernate-announce mailing list