wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes No Persistent Classes found for Query Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "No Persistent Classes found for Query Class" Watch "No Persistent Classes found for Query Class" New topic
Author

No Persistent Classes found for Query Class

Phoenix Kilimba
Ranch Hand

Joined: Oct 10, 2006
Posts: 64
Dear Sirs et Madames,

I am trying to experiment with polymorphism in hibernate and have read somewhere that it is possible to query for subtypes of a class even if the subclass itself is not mapped (Hibernate in Action page 252). However when I try it, I do not get the desired result. Here is the superclass:



The subclass:



DAO class:



When I run main, I get the following output:

init:
deps-module-jar:
deps-ear-jar:
deps-jar:
compile-single:
run-main:
Jun 23, 2009 3:00:24 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
Jun 23, 2009 3:00:24 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
Jun 23, 2009 3:00:24 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jun 23, 2009 3:00:24 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Jun 23, 2009 3:00:24 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jun 23, 2009 3:00:25 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jun 23, 2009 3:00:25 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Jun 23, 2009 3:00:25 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/UserPrivileges.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/Privilege.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/Enumerator.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/UserType.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/User.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/Location.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/openhrs/common/LocationType.hbm.xml
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.UserPrivilege -> user_privileges
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.Privilege -> privilege
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.Enumerator -> enumerator
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.UserType -> user_type
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.User -> users
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.Location -> locations
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.openhrs.entities.LocationType -> location_types
Jun 23, 2009 3:00:26 PM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
INFO: Hibernate Validator not found: ignoring
Jun 23, 2009 3:00:26 PM org.hibernate.mapping.RootClass checkCompositeIdentifier
WARNING: composite-id class does not override equals(): org.openhrs.entities.UserPrivilege
Jun 23, 2009 3:00:26 PM org.hibernate.mapping.RootClass checkCompositeIdentifier
WARNING: composite-id class does not override hashCode(): org.openhrs.entities.UserPrivilege
Jun 23, 2009 3:00:26 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jun 23, 2009 3:00:26 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jun 23, 2009 3:00:26 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Jun 23, 2009 3:00:26 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/OpenHRS
Jun 23, 2009 3:00:26 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.67-community-nt
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
Jun 23, 2009 3:00:29 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Jun 23, 2009 3:00:29 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Jun 23, 2009 3:00:29 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Jun 23, 2009 3:00:29 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Jun 23, 2009 3:00:29 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Jun 23, 2009 3:00:29 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jun 23, 2009 3:00:29 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Jun 23, 2009 3:00:30 PM org.hibernate.hql.QuerySplitter concreteQueries
WARNING: no persistent classes found for query class: from org.openhrs.entities.Region
BUILD SUCCESSFUL (total time: 12 seconds)

Why is it insisting it cannot find the persisted class when the book says the subclass does not have to be persisted as long as the superclass is?

Any help greatly appreciated. Thanks

You are what you know
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Wehn I look at that page, I see parent types in the from clause. like Object, or Serializable. In the case of the BillingDetails, I already know that CreditCard and BankAccount are also mapped inheritance classes in the Caveat Emptor app from which those classes came from.

I think those subclasses need to be mapped.

As far as


that it is possible to query for subtypes of a class even if the subclass itself is not mapped (Hibernate in Action page 252).


It doesn't say that in that page, it has those two parts, but as separate things.

When it talks about the from clause, it just says that any type will do, and then shows parent types, like Object and Serializable.

In the paragraph before that, it talks about result object types. Where if you query in the form with From BillingDetails, the actual instances that return will be of types BankAccount and CreditCard because BillingDetails is an abstract class and you can't instantiate them, so that is with the subclasses being mapped that Hibernate can do that and then you can also do things like "From BankAccount" and only get Bank accoutns and no Credit Cards.

Hope that clears it up.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No Persistent Classes found for Query Class