Hi,
I am new in GWT and I like this concept, so I've tried to create GWT
application with hibernate support. I have a problem with Object
mapping.
This is my "persistence.properties" file (it is in src folder of my
project):
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.url = jdbc:mysql://localhost:3306/gwt_web_shop_db
hibernate.connection.username = root
hibernate.connection.password = somepass
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.MySQLDialect
hibernate.connection.pool_size = 4
hibernate.show_sql = true
hibernate.hbm2ddl.auto = create
hibernate.archive.autodetection = class
When I run application (in Eclipse) everything goes ok with this code:
public UserServiceImpl(){
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("");
em = emf.createEntityManager();
}
,but when I try something like this:
Query q = em.createQuery("select u from User where u.username
= :username");
q.setParameter("username", username);
List<User> res = q.getResultList();
I get this Exception: java.lang.IllegalArgumentException:
org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [select
u from User where u.username = :username]
Here is my User.java class:
package gwtWebshop.client.entities;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity(name="User")
@Table(name="users")
public class User implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private int id;
private String username;
public User() {
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int getId() {
return id;
}
public String getUsername() {
return username;
}
public void setId(int id) {
this.id = id;
}
public void setUsername(String username) {
this.username = username;
}
}
I concluded that the mapping is not done automatically based on the
annotation, but I do not know how to change that.
Please help me and tell me the right way to do this.
Thank you.
Regards,
Nenad
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.