-->
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.  [ 4 posts ] 
Author Message
 Post subject: serializable POJOs
PostPosted: Thu May 19, 2005 2:55 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
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

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject: Re: serializable POJOs
PostPosted: Thu May 19, 2005 3:01 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
[quote="pkrouse"

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[/quote]

This isn't a Hibernate issue, it's a java Serialization issue.

And I don't think you should to map it to the database. It can be hard coded at the Class-level. It's main purpose is to make sure that if you serialize a Class, and then later try to reload it, it's the same "version" of the class. Obviously this means that if you and/remove columns or change datatypes, you should modify this value.

(Hibernate works fine without it.)

http://java.sun.com/j2se/1.5.0/docs/api ... zable.html


Top
 Profile  
 
 Post subject: serializable POJOS
PostPosted: Thu May 19, 2005 3:10 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
OK, then how do I stop Hibernate from making my POJOs serializable? I didn't really think I needed it, but Hibernate is putting "implements Serializable" in my POJOs.

--PK

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject: Re: serializable POJOS
PostPosted: Thu May 19, 2005 3:19 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
pkrouse wrote:
OK, then how do I stop Hibernate from making my POJOs serializable? I didn't really think I needed it, but Hibernate is putting "implements Serializable" in my POJOs.

--PK


You can just ignore the warning messages.


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