Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.2
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.txdx.pojo">
<class name="Patient" table="patients">
<id name="id" column="patient_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="salutation" type="string" length="4" not-null="true" />
<property name="firstName" type="string" length="25" not-null="true" />
<property name="initial" type="string" length="1" not-null="false"/>
<property name="lastName" type="string" length="25" not-null="true" />
<property name="suffix" type="string" length="3" not-null="false"/>
<property name="haddr1" type="string" length="35" not-null="true" />
<property name="haddr2" type="string" length="35" not-null="false"/>
<property name="hcity" type="string" length="15" not-null="true" />
<property name="hstate" type="string" length="2" not-null="true" />
<property name="hzip" type="string" length="10" not-null="true" />
<property name="hphone" type="string" length="13" not-null="false"/>
<property name="hcell" type="string" length="13" not-null="false"/>
<property name="hphoneother" type="string" length="13" not-null="false"/>
<property name="hwebsite" type="string" length="50" not-null="false"/>
<property name="DOB" type="date"/>
<property name="SSN" type="string" length="11" not-null="false"/>
<property name="workplace" type="string" length="35" not-null="false"/>
<property name="waddr1" type="string" length="35" not-null="false" />
<property name="waddr2" type="string" length="35" not-null="false"/>
<property name="wcity" type="string" length="15" not-null="false" />
<property name="wstate" type="string" length="2" not-null="false" />
<property name="wzip" type="string" length="10" not-null="false" />
<property name="wphone" type="string" length="13" not-null="false"/>
<property name="wphone2" type="string" length="13" not-null="false"/>
<property name="wphoneother" type="string" length="13" not-null="false"/>
<property name="wwebsite" type="string" length="50" not-null="false"/>
<!-- TODO: link to authorized contact here, 1-to-1 contact null OK -->
<property name="serialVersionUID" type="long"/>
<bag name="Rxs" cascade="all" inverse="true" lazy="false" order-by="rxDate">
<key column="patient_id"/>
<one-to-many class="com.txdx.pojo.Rx"/>
</bag>
<!--
<set name="Rxs" cascade="all" inverse="true" lazy="false">
<key column="patient_id"/>
<one-to-many class="com.txdx.pojo.Rx"/>
</set>
-->
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.txdx.pojo">
<class name="Rx" table="rxs">
<!-- we will try this without an ID for now... -->
<id name="id" column="rx_id"
type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="brandName" type="string" length="35" not-null="true"/>
<property name="genericName" type="string" length="35"/>
<property name="rxDate" type="date"/>
<property name="dosage" type="float"/>
<property name="instructions" type="string"/>
<property name="serialVersionUID" type="long"/>
<many-to-one name="patient" class="com.txdx.pojo.Patient" column="patient_id" not-null="true"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
MySQL
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
OK I am starting with Hibernate 3, and nave found nothing on this while searching the forums. When I use the above mapping documents to create my POJOs, I get usable code, but both classes implement serializable and give the following warning:
1 The serializable class Patient does not declare a static final serialVersionUID field of type long Patient.java MedicalRCP/src/com/txdx/pojo line 7 May 19, 2005 1:46:10 PM
Rx does the same. How can I declare long serialVersionUID in my mapping document? When I try that, hibernate maps it as Long, not long.
--PK