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]
|
|