-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Why I get a "not mapping" error with the Category?
PostPosted: Mon Oct 08, 2007 2:02 pm 
Newbie

Joined: Wed Feb 07, 2007 7:55 pm
Posts: 18
I use the component approach of the Cavea Temptor (native) in my application which has the same parent-children relationship scenario. I run into a unmapped error which I can't figure out the cause. I do have the class mapped information when I bring up the application. Can someone point me a direction? The following is the related information.

Hibernate version:
3.1.x

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!--

Mapping file for the Category class

-->
<hibernate-mapping package="com.abc.xyz.domain.directory" default-access="field" auto-import="false">

<class name="Category" table="ilc_directory_category">

<!-- Common id property -->
<id name="id" type="int" unsaved-value="null" >
<generator class="native">
<param name="sequence">ilc_directory_category_id_seq</param>
</generator>
</id>

<!-- A versioned entity -->
<version name="version" column="OBJ_VERSION"/>

<!-- Name is limited to 255 characters.-->
<property name="name" type="string">
<column name="NAME" not-null="true" length="255"/>
</property>

<!-- Immutable property -->
<property name="created" column="CREATED" type="timestamp" update="false" not-null="true"/>

<!-- The non-inverse side of the one-to-many/many-to-one association -->
<many-to-one name="parentCategory" class="Category" foreign-key="ILC_DIRECTORY_CATEGORY_PARENT_ID_FKEY">
<column name="PARENT_CATEGORY_ID" not-null="false"/>
</many-to-one>

<!-- The inverse side of the one-to-many/many-to-one association, we
use a bag mapping, iteration order of this collection is by
category name. -->
<bag name="childCategories" cascade="save-update, merge" inverse="true" order-by="NAME asc">
<key column="PARENT_CATEGORY_ID"/>
<one-to-many class="Category"/>
</bag>

<set name="categorizedEntryComponents" table="ilc_categorized_entry_component">
<key column="CATEGORY_ID" foreign-key="ILC_CATEGORIZED_ENTRY_COMPONENT_CATEGORY_ID_FKEY"/>
<composite-element class="CategorizedEntryComponent">
<parent name="category"/>

<many-to-one name="entry"
column="ENTRY_ID"
class="Entry"
not-null="true"
update="false"
foreign-key="ILC_CATEGORIZED_ENTRY_COMPONENT_ENTRY_ID_FKEY"/>

<property name="username"
type="string"
column="ADDED_BY_USER"
not-null="true"
update="false"/>

<property name="dateAdded"
column="ADDED_ON"
type="timestamp"
not-null="true"
update="false"/>

</composite-element>
</set>

</class>

<!--
There can never be two categories with the same name at
the same "level", that is, they can't have the same parent
category. This is protected with a unique constraint.
-->
<database-object>
<create>
alter table ilc_directory_category add constraint UNIQUE_SIBLINGS
unique (NAME, PARENT_CATEGORY_ID)
</create>
<drop>
alter table ilc_directory_category drop constraint UNIQUE_SIBLINGS
</drop>
</database-object>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
from Category c left join fetch c.categorizedEntryComponents ec left join ec.entry e left join e.addresses a where c.id = :catId
Full stack trace of any exception that occurs:
Data access failure: Category is not mapped [from Category c left join fetch c.categorizedEntryComponents ec left join ec.entry e left join e.addresses a where c.id = :catId;
nested exception is org.hibernate.hql.ast.QuerySyntaxException: Category is not mapped [from Category c left join fetch c.categorizedEntryComponents ec left join ec.entry e left join e.addresses a where c.id = :catId]

org.springframework.orm.hibernate3.HibernateQueryException: Category is not mapped [from Category c left join fetch c.categorizedEntryComponents ec left join ec.entry e left join e.addresses a where c.id = :catId];
nested exception is org.hibernate.hql.ast.QuerySyntaxException: Category is not mapped [from Category c left join fetch c.categorizedEntryComponents ec left join ec.entry e left join e.addresses a where c.id = :catId] at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:640) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:378) at
org.springframework.orm.hibernate3.HibernateTemplate.findByNamedParam(HibernateTemplate.java:873) at
...
Name and version of the database you are using:
PostgreSQL 8.1
The generated SQL (show_sql=true):
None
The Spring mapping output information:


INFO org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues:300 - Mapping class: com.abc.xyz.domain.directory.AddressEntity -> ilc_directory_address
INFO org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues:300 - Mapping class: com.abc.xyz.domain.directory.Category -> ilc_directory_category
INFO org.hibernate.cfg.HbmBinder.bindCollection:1422 - Mapping collection: com.abc.xyz.domain.directory.Category.categorizedEntryComponents -> ilc_categorized_entry_component
INFO org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues:300 - Mapping class: com.abc.xyz.domain.directory.Comment -> ilc_directory_comment
INFO org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues:300 - Mapping class: com.abc.xyz.domain.directory.Entry -> ilc_directory_entry
INFO org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory:665 - Building new Hibernate SessionFactory
INFO org.hibernate.cfg.HbmBinder.bindCollectionSecondPass:2385 - Mapping collection: com.abc.xyz.domain.directory.Category.childCategories -> ilc_directory_category
INFO org.hibernate.cfg.HbmBinder.bindCollectionSecondPass:2385 - Mapping collection: com.abc.xyz.domain.directory.Entry.addresses -> ilc_directory_address


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 9:19 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
It may be one of the followings:
    1. Is a mapping file, usually named Category.hbm.xml, to tell Hibernate how the class is mapped into a DB table?
    2. Is the mapping file Category.hbm.xml listed in the Hibernate configuration file?
    3. Is the mapping file in the physical path as what it is in the Hibernate configuration file


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 2:22 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
You're specifying 'auto-import="false"', which specifically disables unqualified class references in HQL (the default is true). I would try removing that attribute setting. If that doesn't fix it, I might try removing the package attribute and making all the class references absolute.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 7:32 pm 
Newbie

Joined: Wed Feb 07, 2007 7:55 pm
Posts: 18
dkarr wrote:
You're specifying 'auto-import="false"', which specifically disables unqualified class references in HQL (the default is true). I would try removing that attribute setting. If that doesn't fix it, I might try removing the package attribute and making all the class references absolute.


That solves the problem. I always have the auto-import set to true with this mapping exception. I can't remember why I did so. Thans very much for pointing out the cause.
----
Ok, now I remember why I set the auto-import to false. I had two model classes with the same name under differenct packages. When I had the auto-import set to true or be its default value, Hibernate didn't know what one shall be used. I need to rename one of them to aviod the side effect.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.