-->
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: "Unknown Entity Class" - How to set the PK?
PostPosted: Thu Jul 21, 2005 5:58 pm 
Beginner
Beginner

Joined: Wed Jul 20, 2005 2:57 pm
Posts: 28
Hi,

I have a table "xpackage" and a table "xclass".
"xclass" has a primary key (xclassname,xpackageid).

I generated the DAOs from the mappingfiles. So far everything seems to be fine.

I don't know how to set the primarykey of the xclass. I get a net.sf.hibernate.MappingException: Unknown entity class: model.genDAO.Xclass

What does that mean? Is something wrong with my db-tables or is it caused by my rubbish javacode? ;)

My xclass mapping looks like that:
<hibernate-mapping package="model.genDAO">
<class
name="Xclass"
table="xclass"
>
<composite-id name="PK" class="XclassPK">
<key-property
name="name"
column="name"
type="string"
/>
<key-many-to-one
name="package"
class="Xpackage"
column="package"
/>
</composite-id>

<property
...
</class>
</hibernate-mapping>

How can the primary key of the table xclass be set???

I tried it with:
...
try {
_RootDAO.initialize();

XpackageDAO xpdao = new XpackageDAO();
XclassDAO dao = new XclassDAO();
Xclass xc = new Xclass();
XclassPK pk = new XclassPK();

pk.setName(xclass.getName());
pk.setPackage(xpdao.get(packageID));

Transaction tx = dao.beginTransaction(dao.getSession());

xc.setIsabstract(xclass.isAbstract());
xc.setIsinterface(xclass.isInterface());
dao.save(xc); // <-- here, the exception is thrown.

} catch (HibernateException e) {
e.printStackTrace();
...

Thanks in advance,
Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 8:47 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
Unknown entity class means that the session factory has not been configured with the mapping for the class you are supplying to the session.

Please post your hibernate configuration file, the hibernate version being used, and any other third-party (e.g. Spring) frameworks that may be involved if you need further help. For a full list of requirements for solving the typical problems, please see HowToAskForHelp


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 11:03 am 
Beginner
Beginner

Joined: Wed Jul 20, 2005 2:57 pm
Posts: 28
I found the reason why the entity class could not be found. I feel ashamed... In the hibernate.cfg.xml I commented the xlass out. I forgot that.
Thanks CollinL.

Regards, Kurt


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.