Try any solution but still “no persistent classes found for query class”



I’m beginner in Hibernate and I’m just trying to fetch some data from my DB via hibernate but I failed and I got this error :

no persistent classes found for query class: from model.ItemClass

I also try some other query with class.getSimpleName() but I failed again.

These are the output I recieved :

Apr 25, 2019 10:05:32 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.4.2.Final}
Apr 25, 2019 10:05:33 PM <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
Apr 25, 2019 10:05:33 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Apr 25, 2019 10:05:33 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/shopping]
Apr 25, 2019 10:05:33 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
Apr 25, 2019 10:05:33 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
Apr 25, 2019 10:05:33 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 50 (min=1)
Apr 25, 2019 10:05:35 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Apr 25, 2019 10:05:36 PM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService
INFO: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
Apr 25, 2019 10:05:36 PM org.hibernate.hql.internal.QuerySplitter concreteQueries
WARN: HHH000183: no persistent classes found for query class: from model.ItemClass

And these are my files :


<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD//EN"
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/shopping</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.username">root</property>
        <property name="connection.password">avada</property>
        <property name="connection.pool_size">50</property>
        <mapping resource="model/ItemClass.hbm.xml"/>
        <mapping class="model.ItemClass"/>

        <!-- DB schema will be updated if needed -->
        <!-- <property name="">update</property> -->


import model.ItemClass;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.query.Query;
import org.hibernate.service.ServiceRegistry;

import java.util.List;

public class Testt {

    public static void main(String[] args) {

        Configuration configuration = new Configuration().configure("hibernate.cfg.xml");

        StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();


        ServiceRegistry serviceRegistry =;

        SessionFactory MySessionFactory = configuration.buildSessionFactory(serviceRegistry);

        try (Session session = MySessionFactory.openSession()) {
            Query query = session.createQuery("from model.ItemClass");
            List<model.ItemClass> itemClasses = query.list();






package model;

import java.sql.Date;
import java.util.Objects;

public class ItemClass {
    private int id;
    private String name;
    private Integer price;
    private String imageUrl;
    private Integer availableAmount;
    private Integer bought;
    private Date publishTime;
    private String author;

    public int getId() {
        return id;

    public void setId(int id) { = id;

    public String getName() {
        return name;

    public void setName(String name) { = name;

    public Integer getPrice() {
        return price;

    public void setPrice(Integer price) {
        this.price = price;

    public String getImageUrl() {
        return imageUrl;

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;

    public Integer getAvailableAmount() {
        return availableAmount;

    public void setAvailableAmount(Integer availableAmount) {
        this.availableAmount = availableAmount;

    public Integer getBought() {
        return bought;

    public void setBought(Integer bought) {
        this.bought = bought;

    public Date getPublishTime() {
        return publishTime;

    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;

    public String getAuthor() {
        return author;

    public void setAuthor(String author) { = author;

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ItemClass itemClass = (ItemClass) o;
        return id == &&
                Objects.equals(name, &&
                Objects.equals(price, itemClass.price) &&
                Objects.equals(imageUrl, itemClass.imageUrl) &&
                Objects.equals(availableAmount, itemClass.availableAmount) &&
                Objects.equals(bought, itemClass.bought) &&
                Objects.equals(publishTime, itemClass.publishTime) &&

    public int hashCode() {
        return Objects.hash(id, name, price, imageUrl, availableAmount, bought, publishTime, author);


<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

    <class name="model.ItemClass" table="item" schema="shopping">
        <id name="id">
            <column name="id" sql-type="int(11)"/>
        <property name="name">
            <column name="name" sql-type="varchar(45)" length="45"/>
        <property name="price">
            <column name="price" sql-type="int(11)" not-null="true"/>
        <property name="imageUrl">
            <column name="imageURL" sql-type="varchar(45)" length="45" not-null="true"/>
        <property name="availableAmount">
            <column name="available_amount" sql-type="int(11)" not-null="true"/>
        <property name="bought">
            <column name="bought" sql-type="int(11)" not-null="true"/>
        <property name="publishTime">
            <column name="publish_time" sql-type="date" not-null="true"/>
        <property name="author">
            <column name="author" sql-type="varchar(45)" length="45"/>

and this is my project’s directory structure:

Would you help me plz ?