-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Mapping Exception
PostPosted: Wed Jan 30, 2008 6:18 pm 
Newbie

Joined: Wed Jan 30, 2008 6:08 pm
Posts: 4
This is driving me crazy and I'm on a tight schedule to get this done.

I have the following class and named query defined:


Code:
---

package com.XXX.YYY.domain.lookup;
      
import com.XXX.AAA.domain.support.ZZZ;

public class Relation extends ZZZ{
   private Integer lookupRelationId;
   private Integer sectionId;
   private String lookupRelationName;
   private String srcFieldName;
   private String tgtFieldName;
   private Integer lookupAdminId;
..... snip getters and setters ....

---

<hibernate-mapping package="com.XXX.YYY.domain.BBB">

... snip lots of class mappings and named queries ...

   <sql-query name="etofRelation" cacheable="false" callable="false">
      <return class="com.XXX.YYY.domain.lookup.Relation" lock-mode="read">
         <return-property name="lookupRelationId" column="lookup_relation_id"/>
         <return-property name="sectionId" column="section_id"/>
         <return-property name="lookupRelationName" column="lookup_relation_name"/>
         <return-property name="srcFieldName" column="source_field_name"/>
         <return-property name="tgtFieldName" column="target_field_name"/>
         <return-property name="lookupAdminId" column="lookup_admin_id"/>
      </return>
      select lookup_relation_id, section_id, lookup_relation_name, source_field_name, target_field_name, lookup_admin_id
         from SOME_TABLE where
         section_id = :section and
         lookup_relation_name = :relation_name
   </sql-query>





My table is defined as follows:

Code:
create table SOME_TABLE
        (   lookup_relation_id      NUMBER(11,0) primary key,
            section_id              NUMBER(11,0),
            lookup_relation_name    VARCHAR2(50),
            source_field_name        VARCHAR2(50),
            target_field_name       VARCHAR2(50),
            lookup_admin_id         NUMBER(11,0) NOT NULL,
            CONSTRAINT fk_relations_lu_admin_id
                FOREIGN KEY (lookup_admin_id)
                REFERENCES  OTHER_TABLE (lookup_admin_id),
            CONSTRAINT fk_relations_section_id
                FOREIGN KEY (section_id)
                REFERENCES  ANOTHER_TABLE (section_id)
        )




My localhost fails to start with the following exception:

Code:

Error in named query: etofRelation
org.hibernate.MappingException: Unknown entity: com.XXX.YYY.domain.lookup.Relation
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:514)
.... snip long stack trace ....



All of this seems to be correct to me. I can't figure out for the life of me why hibernate doesn't like my named query. Does anybody have any idea what's going wrong here?

Thanks,


matt muscari


Top
 Profile  
 
 Post subject: Re: Hibernate Mapping Exception
PostPosted: Wed Jan 30, 2008 7:10 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Does com.XXX.YYY.domain.lookup.Relation match the class specified in <class name="[HERE]" ..> ?



Farzad-


Top
 Profile  
 
 Post subject: Re: Hibernate Mapping Exception
PostPosted: Wed Jan 30, 2008 7:34 pm 
Newbie

Joined: Wed Jan 30, 2008 6:08 pm
Posts: 4
farzad wrote:
Does com.XXX.YYY.domain.lookup.Relation match the class specified in <class name="[HERE]" ..> ?



Farzad-


Yes


Top
 Profile  
 
 Post subject: Re: Hibernate Mapping Exception
PostPosted: Wed Jan 30, 2008 9:39 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
mgmuscari wrote:
Yes




what if you temporarily remove the package name on hibernate mapping? if not give me the whole mapping file.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 11:59 pm 
Newbie

Joined: Wed Jan 30, 2008 6:08 pm
Posts: 4
Farzad,

i'll give that a try tomorrow at work.

it occurred to me that the mapping exception may be caused because my columns are NUMBER types but i'm trying to map them to java Integers. i'm going to see if making those fields Double objects fixes the problem.


Top
 Profile  
 
 Post subject: Re: Hibernate Mapping Exception
PostPosted: Thu Jan 31, 2008 10:48 am 
Newbie

Joined: Wed Jan 30, 2008 6:08 pm
Posts: 4
farzad wrote:
mgmuscari wrote:
Yes




what if you temporarily remove the package name on hibernate mapping? if not give me the whole mapping file.



Farzad-



Farzad,

I tried moving the named query into a separate HBM mapping where the package matches the Relation class' package. This seemed to do the trick. I thought you could fully qualify a class name from another package, but I guess I wrong.

Thanks for your suggestions, they put me on the right track.


-mgm


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.