Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.0[/b]
[b]Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://192.168.2.1/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.gloptv.smsc.Customer"
table="customer"
lazy="true"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<cache usage="nonstrict-read-write" />
<id
name="id"
column="id"
type="int"
>
<generator class="sequence">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Customer.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="name"
not-null="true"
/>
<property
name="isDeleted"
type="boolean"
update="true"
insert="true"
access="property"
column="is_deleted"
/>
<many-to-one
name="user"
class="com.gloptv.smsc.User"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="property"
column="user_id"
not-null="true"
/>
<set
name="keywords"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
order-by="name"
where="is_deleted = 'false'"
>
<key
column="customer_id"
>
</key>
<one-to-many
class="com.gloptv.smsc.Keyword"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Customer.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
[/b]
[b]Code between sessionFactory.openSession() and session.close():[/b]
[b]Full stack trace of any exception that occurs:[/b]
[b]Name and version of the database you are using:postgresql 8.0[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:[/b]
Hi everyone, my problem is as follows. I have a class named Customer from which I've generated the file Customer.hbm.xml as shown above. When I tried to obtain a session as follows:
..................
Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
SessionFactory sessionFactory = configuration.buildSessionFactory();
Session session = sessionFactory.openSession();
.................
I got a 'NoClassDefFoundError', I searched and found that all my classes are here. Something very strange. After hours of debugging I found that the error comes from the server ip address. In fact the ip address of my server has been changed and in my Customer.hbm.xml file the ip address has not been changed. Consequently when hibernate searches for the following file:
http://192.168.2.1/hibernate-mapping-3.0.dtd, it did not find it and throws a NoClassDefFoundError.
I think Hibernate could have thrown a clearer description of the error.
thanks