Problem is SOLVED:
I needed to add all my annotated classes to persistence.xml, like:
Code:
<class>at.audiv8.cardb.client.data.Rim</class>
before the <properties> section.
Bastian
Original post:
Hi,
I have generated a list of classes with annotations for a database application and the corresponding DAOs using GWT as frontend. When calling the method's of the DAOs locally in a Java application, everything works fine. When deploying the application on a tomcat server, I get the following error (example):
[WARN] no persistent classes found for query class: from at.audiv8.cardb.client.data.Rim
code of Rim is:
Code:
package at.audiv8.cardb.client.data;
import javax.persistence.*;
import com.google.gwt.user.client.rpc.IsSerializable;
@Entity
@Table(name = "rim")
public class Rim implements IsSerializable
{
static final long serialVersionUID = 1;
public Rim()
{
super();
}
@Id
@GeneratedValue
@Column(name = "id")
private int id;
@OneToOne(cascade = CascadeType.ALL, optional = false)
@JoinColumn(name = "id_info", unique = true)
private Info info;
@Column(name = "vendor", length = 30)
private String vendor;
@Column(name = "original")
private boolean original;
@Column(name = "model", length = 50)
private String model;
@Column(name = "width")
private float width;
@Column(name = "inches")
private int inches;
@Column(name = "admitted")
private boolean admitted;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public Info getInfo()
{
return info;
}
public void setInfo(Info info)
{
this.info = info;
}
public String getVendor()
{
return vendor;
}
public void setVendor(String vendor)
{
this.vendor = vendor;
}
public boolean isOriginal()
{
return original;
}
public void setOriginal(boolean original)
{
this.original = original;
}
public String getModel()
{
return model;
}
public void setModel(String model)
{
this.model = model;
}
public float getWidth()
{
return width;
}
public void setWidth(float width)
{
this.width = width;
}
public int getInches()
{
return inches;
}
public void setInches(int inches)
{
this.inches = inches;
}
public boolean isAdmitted()
{
return admitted;
}
public void setAdmitted(boolean admitted)
{
this.admitted = admitted;
}
}
RimDAO:
Code:
public class RimDAO extends GenericHibernateDAO<Rim, Integer>
{
}
GenericHibernateDAO:
Code:
public class GenericHibernateDAO<T, ID> implements GenericDAO<T, ID>, PreconfigDAO
{
private Class<T> persistentClass;
private String tablename;
private EntityManager em;
@SuppressWarnings("unchecked")
public GenericHibernateDAO()
{
this.persistentClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
tablename = persistentClass.getName();
}
public EntityManager getEntityManager()
{
return em;
}
public void setEntityManager(EntityManager em)
{
this.em = em;
}
public String getTablename()
{
return tablename;
}
public Class<T> getPersistentClass()
{
return persistentClass;
}
public T findById(ID id)
{
return em.find(persistentClass, id);
}
@SuppressWarnings("unchecked")
public List<T> findAll()
{
return em.createQuery("from " + tablename).getResultList();
}
public T persist(T entity)
{
em.persist(entity);
return entity;
}
public void remove(T entity)
{
em.remove(entity);
}
public void flush()
{
em.flush();
}
public void clear()
{
em.clear();
}
}
Hibernate version:hibernate annotations 3.3.1
hibernate core 3.2.6
Mapping documents:None (?) as I use Annotations
Code between sessionFactory.openSession() and session.close():Code:
public List<Rim> getRims()
{
DBSession session = manager.createSession();
try
{
return session.getRimDAO().findAll();
}
finally
{
session.close();
}
}
Name and version of the database you are using:
mySQL Version: 5.0.37
Thank you very much for any help on this
Bastian