troubleshooting Question

Hibernate: no persistent classes found for query class: from mapped.PersistentTable1

Avatar of stephan_zehnder
stephan_zehnder asked on
JavaJava EE
35 Comments2 Solutions13617 ViewsLast Modified:
I'm doing a little test with hibernate3 and annotations. Here is what i have:

================================== configuration =============================
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="connection.url">jdbc:postgresql:horizon://localhost</property>
    <property name="connection.username">nh_user</property>
    <property name="connection.password">nh_user</property>
    <property name="dialect ">org.hibernate.dialect.ProgressDialect</property>
    <!-- property name="cache.provider_class">net.sf.ehcache.hibernate.Provider</property-->
    <property name="show_sql">true</property>
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
   
   
    <!-- mapping package="mapped" /-->
    <mapping class="mapped.PersistentTable1" />
    <mapping class="mapped.PersistentTable2" />
  </session-factory>
</hibernate-configuration>


========================================== PersistentTable1 ===========================================
/*
 * $Id$
 *
 * Copyright (c) 2006 Nexus Telecom AG
 * Feldbachstrasse, 8634 Hombrechtikon, Switzerland
 * All Rights Reserved.
 */
package mapped;

import java.util.Set;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Entity;
import org.hibernate.annotations.Table;

@Entity
@Table(name="table1")
public class PersistentTable1 {

  private int id;
  private String text;
  private Set table2s;
 
  public PersistentTable1() {
  }

  @Id
  public int getId() {
    return id;
  }

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

  public String getText() {
    return text;
  }

  public void setText(String text) {
    this.text = text;
  }

  @OneToMany
  @JoinColumn(name="table1_id")
  public Set getTable2s() {
    return table2s;
  }

  public void setTable2s(Set table2s) {
    this.table2s = table2s;
  }
 

}

========================================== PersistentTable2 ===========================================
...


========================================== Main ===================================================
public class Main {

  public static void main(String[] args) {
    Session session = HibernateUtil.getSession();
    Query query = session.createQuery("from mapped.PersistentTable1");
    List<PersistentTable1> table1s = (List<PersistentTable1>)query.list();
   
    System.out.println("");
  }
}

========================================== log ===============================================

16:12:37,732  INFO Environment:479 - Hibernate 3.1.1
16:12:37,747  INFO Environment:509 - hibernate.properties not found
16:12:37,794  INFO Environment:525 - using CGLIB reflection optimizer
16:12:37,809  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
16:12:37,918  INFO Configuration:1296 - configuring from resource: /hibernate.cfg.xml
16:12:37,918  INFO Configuration:1273 - Configuration resource: /hibernate.cfg.xml
16:12:38,323  INFO Configuration:1407 - Configured SessionFactory: null
16:12:38,385  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
16:12:38,385  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
16:12:38,385  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
16:12:38,401  INFO DriverManagerConnectionProvider:80 - using driver: org.postgresql.Driver at URL: jdbc:postgresql:horizon://localhost
16:12:38,401  INFO DriverManagerConnectionProvider:86 - connection properties: {user=------, password=****}
16:12:38,603  INFO SettingsFactory:77 - RDBMS: PostgreSQL, version: 8.1.1
16:12:38,603  INFO SettingsFactory:78 - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.0 JDBC3g with SSL (build 311)
16:12:38,634  INFO Dialect:103 - Using dialect: org.hibernate.dialect.PostgreSQLDialect
16:12:38,712  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
16:12:38,712  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:12:38,712  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
16:12:38,728  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
16:12:38,728  INFO SettingsFactory:136 - JDBC batch size: 15
16:12:38,728  INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
16:12:38,728  INFO SettingsFactory:144 - Scrollable result sets: enabled
16:12:38,728  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
16:12:38,728  INFO SettingsFactory:160 - Connection release mode: auto
16:12:38,728  INFO SettingsFactory:187 - Default batch fetch size: 1
16:12:38,728  INFO SettingsFactory:191 - Generate SQL with comments: disabled
16:12:38,728  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
16:12:38,728  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:12:38,728  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
16:12:38,728  INFO SettingsFactory:203 - Query language substitutions: {}
16:12:38,728  INFO SettingsFactory:209 - Second-level cache: enabled
16:12:38,728  INFO SettingsFactory:213 - Query cache: disabled
16:12:38,743  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
16:12:38,743  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
16:12:38,743  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
16:12:38,743  INFO SettingsFactory:257 - Echoing all SQL to stdout
16:12:38,743  INFO SettingsFactory:264 - Statistics: disabled
16:12:38,743  INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
16:12:38,743  INFO SettingsFactory:283 - Default entity-mode: pojo
16:12:38,790  INFO SessionFactoryImpl:153 - building session factory
16:12:38,790  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
16:12:38,868  WARN QuerySplitter:116 - no persistent classes found for query class: from mapped.PersistentTable1

Why isn't it finding the persistent class? The configuration is in the classpath.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 35 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 35 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros