QuerySyntaxException: xxx is not mapped

Hello!
I have a problem with invoking HQL-query to the essence (Pushdata). But i received exception
“QuerySyntaxException: Pushdata is not mapped”

 @Entity
@Table(name="pushmaster")
public class Pushdata {

@Id
@SequenceGenerator(name = "pushmaster_id_seq",
 sequenceName = "pushmaster_id_seq",
 allocationSize = 1)
 @GeneratedValue (strategy = GenerationType.SEQUENCE,
 generator = "pushmaster_id_seq")
 @Column(name="id", unique = true)
 public int id;

 private String title;
 private String content;

 public Pushdata (){
}

 public Pushdata (String title, String content){
this.title=title;
this.content=content;
}

 @Column(name = "title")
  public String getTitle() {
return title;
 }

 public void setTitle(String title) {
this.title = title;
}

 @Column(name = "content")
 public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public int getId() {
return id;
}

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

Actually, the query

(List<Pushdata>)
            factoryClass.getSessionFactory().
                    openSession().createQuery(" from Pushdata" ).list();

`Configuration

<hibernate-configuration>
<session-factory>

    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL94Dialect</property>

    <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/</property>

    <property name="hibernate.connection.username">postgres</property>
    <property name="hibernate.connection.password">password</property>

    <property name="connection_pool_size">1</property>

    <property name="hbm2ddl.auto">update</property>

    <property name="hibernate.connection.autocommit">true</property>

    <property name="show_sql">true</property>

    <mapping class="ru.spb.Pushdata"/>

</session-factory>

Could anyone help me, please
Thanks,

Use these test case templates to get an example that works just fine.

Afterward, you can compare it in debug with yours and see the difference.

vlad, thank you for advise.
I realised

  public class ORMUnitTestCase extends BaseCoreFunctionalTestCase {

protected Class[] getAnnotatedClasses() {
    return new Class[]{
            Pushdata.class
    };
}
}

and

   public class Main {

    public static void main(String[] args) throws SQLException 
    new ORMUnitTestCase();
}
}

and i have got in log:
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:277)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:256)
at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.(BaseCoreFunctionalTestCase.java:65)

But so far i don't understand how to tread this problem...

There’s a hibernate.properties file that should contain the dialect. Just configure the project via Maven in your IDE and it should work just fine.

But originally my hibernate-configuration file contained this property

 <hibernate-configuration>
 <session-factory>

 <property name="hibernate.dialect"> org.hibernate.dialect.PostgreSQL94Dialect</property>

</session-factory>
</hibernate-configuration>

And I ranged dialect vertions: PostgreSQL94Dialect, PostgreSQL93Dialect, PostgreSQL92Dialect…

The configuration is called by

        Configuration configuration = new Configuration();
         
            configuration.configure(new 
       File(getClass().getClassLoader().getResource("hibernate.cfg.xml").toURI()));
            StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().
                    applySettings(configuration.getProperties());
            sessionFactory = configuration.buildSessionFactory(builder.build());
  1. There’s a whitespace before org.hibernate.dialect.PostgreSQL94Dialect.
  2. If the hibernate.properties is located in the root classpath, you don’t need to provide it to Hibernate as it will be automatically discovered.

Again, this works automatically using those templates so you only have to add your entities and everything will work fine.

Check out the Getting Started Guide as well for a working example.

The problem is solved, by modification of factory-code.

I changed the method applySettings(configuration.getProperties()) on configure().

Further the working code:

Configuration configuration = new Configuration();
configuration.configure();

StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().configure();
sessionFactory = configuration.buildSessionFactory(builder.build());

I used the the Getting Started Guide to solve the issue.

I have the same problem (java - org.hibernate.hql.internal.ast.QuerySyntaxException hibernate entity is not mapped - Stack Overflow) and scanning the entity list after a service it is empty. Have a solution?