-->
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.  [ 2 posts ] 
Author Message
 Post subject: Exception in thread "main" net.sf.hibernate.Mappin
PostPosted: Tue Dec 21, 2004 3:35 am 
Beginner
Beginner

Joined: Tue Dec 21, 2004 3:18 am
Posts: 32
Dear All,
I'm new to hibernate and while trying to excute an Insert query I got this error:

Exception in thread "main" net.sf.hibernate.MappingException: Unknown entity class: java.lang.Integer


Could any help me in this?
Please find the required details.

Hibernate Version:
hibernate 2.1

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

<hibernate-mapping package="hibernate2package">
<class name = "Customer" table ="customer">
<id name="cid" column ="cid">
<generator class ="native"/>
</id>
<property name="cname" column="name"/>
<property name="caddress" column="address"/>
<property name="ctel" column="tel"/>

<bag name="products" table="customerproduct" lazy="true" cascade="save-update">
<key column= "cid"/>
<many-to-many class="Product" column="pid"/>
</bag>
</class>
</hibernate-mapping>

2-Product.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="hibernate2package">

<class name="Product" table="product">
<id name = "pid" column ="pid">
<generator class="native"/>
</id>
<property name= "pname" column="name"/>
<property name="pdescription" column="description"/>
<bag name="customers" table ="customerproduct" lazy="true" inverse="true" cascade="save-update">
<key column= "pid"/>
<many-to-many class="Customer" column="cid"/>
</bag>
<many-to-one name="vid" column="vid" class="Vendor"/>
</class>

</hibernate-mapping>

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

<hibernate-mapping package="hibernate2package">
<class name="Vendor" table="vendor">
<id name="vid" column="vid">
<generator class="native"/>
</id>
<property name="vname" column="name"/>
<property name="vaddress" column="address"/>
<property name="vtel" column="tel"/>
<bag name="products" inverse="true" cascade="all-delete-orphan">
<key column="pid"/>
<one-to-many class="Product"/>
</bag>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Session s = factory.openSession();
Transaction tx = s.beginTransaction();
Product p1 = new Product();
p1.setPname("p1");
p1.setPdescription("product1");
p1.setVid(1);
s.save(p1);
tx.commit();
s.close();

Full stack trace of any exception that occurs:

Exception in thread "main" net.sf.hibernate.MappingException: Unknown entity class: java.lang.Integer
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2710)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2717)
at net.sf.hibernate.impl.SessionImpl.isUnsaved(SessionImpl.java:1100)
at net.sf.hibernate.impl.SessionImpl.nullifyTransientReferences(SessionImpl.java:1046)
at net.sf.hibernate.impl.SessionImpl.nullifyTransientReferences(SessionImpl.java:1032)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:936)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:784)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at hibernate2package.Main.addProduct(Main.java:93)
at hibernate2package.Main.main(Main.java:120)



Name and version of the database you are using:
MySQL Server

The generated SQL (show_sql=true):
No SQL generated

Debug level Hibernate log excerpt:


Thanks in Advance.
Sherihan.[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2004 5:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
my best guess is that you have a property that actually is a java.lang.Integer where it should be reference to POJO

_________________
Max
Don't forget to rate


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