-->
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.  [ 3 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: Unknown entity:
PostPosted: Thu Mar 30, 2006 9:25 am 
Newbie

Joined: Tue Mar 21, 2006 4:25 am
Posts: 13
Hello,

I am trying to find an element by it's id. However it hibernate is raising the exception
org.hibernate.MappingException: Unknown entity: mypackage.common.InterfaceAssignmentDef. Now I use the following code to retrieve an AssignmentDef from it's Id.
Code:
    @SuppressWarnings("unchecked")
    public T findById(ID id, boolean lock) {
        T entity;
        if (lock){
           
            entity = (T) getSession().load(getPersistentClass(), id, LockMode.UPGRADE);
        }
        else{
           
            entity = (T) getSession().load(getPersistentClass(), id);
        }
        return entity;
    }
I had copied this code from an example I had seen on this same website. Now this code works fine for other objects without any problems (Assignments, Schools, etc) However it seems to give a problem on this particular class.

The only difference in this class is that this class (AssignmentsDef) has a List object containing the a list of objects of type Assignment. Then there is another object of type Class that has a List of type Assignment. Therefore the assignment class is like a link table in databases.

Now I searched on the internet and I foound out that it could be from the mapping file not being found. I searched for the mapping file inside the War file and I found it.

I also find a post here talking about a bug that was solved in 3.1, however I downloeaded this and I still could have this problem :(

I do not know what to do next since the code is practically the same as in other classes I have.

thanks and regards,
kcorp


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 9:53 am 
Newbie

Joined: Tue Mar 21, 2006 4:25 am
Posts: 13
Just for further information:

I did this method instead of the other one I placed in my previos post to search by id:
Code:
public SkillDefinition findById(Long id){

   Criteria search = getSession().createCriteria(AssignmentDef.class);
   Criterion uid = Restrictions.eq("id", id);
      
   search.add(uid);
      
   List<InterfaceAssignmentDef> result = search.list();
   InterfaceAssignmentDef assignmentsDef = null;
      
   if(result != null){
         
       skill = result.get(0);
   }
            
   return skill;
}
This worked fine!!

However I am still not a satisfied bunny :) I really want to know why the other method is not working. I am posting the code of the other method again, and explain better how it works:
Code:
@SuppressWarnings("unchecked")
public T findById(ID id, boolean lock) {
   T entity;
   if (lock){
           
      entity = (T) getSession().load(getPersistentClass(), id, LockMode.UPGRADE);
   }
   else{
           
      entity = (T) getSession().load(getPersistentClass(), id);
  }
   return entity;
}
In this method there is use of generics. T and ID are defined when initializing the class. In this case they are initialized as T = InterfaceAssignmentDef and ID = Long. As I said, this works fine in all the other classes I have, it just does not want to work in this one :(

I would be really greatfull to anyone who replies. I have made it worked, however I would not like it to remain working in that way, since it just looks like a hack.

thanks and regards,
kcorp


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 6:37 pm 
Newbie

Joined: Tue Mar 21, 2006 4:25 am
Posts: 13
Please know one knows why this could be happenening? I really can not find an explanation why it is failing :(

reg,
kcorp


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