Connected to the project persistence.xml
, gives an error:
org.hibernate.hql.internal.ast.QuerySyntaxException: table is not mapped
Here is the persistence:
<persistence> <persistence-unit name="jsfProject"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <class>entity.models.UserProfile</class> <properties> <property name="hibernate.connection.url" value="jdbc:mysql://sfmnew.amadeus.kz:54001/temp_autoparser"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.username" value="autoparser_user"/> <property name="hibernate.connection.password" value="autoparser_user03022016"/> <property name="hibernate.archive.autodetection" value="class"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence>
here is the class that describes the table
import javax.persistence.*; import java.io.Serializable; @Entity @Table(name="post") public class UserProfile implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", updatable = false, nullable = false) private Long id = null; @Column(name="body") private String body; public Long getId() { return this.id; } public void setId(final Long id) { this.id = id; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } } EntityManagerFactory emf=Persistence.createEntityManagerFactory("jsfProject"); Query q=emf.createEntityManager().createQuery("select body from post");