<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Artem&#039;s blog &#187; Java entity</title>
	<atom:link href="http://artemgolubev.com/tag/java-entity/feed/" rel="self" type="application/rss+xml" />
	<link>http://artemgolubev.com</link>
	<description>Thoughts on software</description>
	<lastBuildDate>Tue, 20 Apr 2010 18:20:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Algorithm for generating serialVersionUID for java entities</title>
		<link>http://artemgolubev.com/algorithm-for-generating-serialversionuid-for-java-entities/</link>
		<comments>http://artemgolubev.com/algorithm-for-generating-serialversionuid-for-java-entities/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 03:32:11 +0000</pubDate>
		<dc:creator>Artem</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java entity]]></category>
		<category><![CDATA[serialVersionUID]]></category>

		<guid isPermaLink="false">http://artemgolubev.com/algorithm-for-generating-serialversionuid-for-java-entities/</guid>
		<description><![CDATA[Here is some way of generating serialVersionUID for java entities.
It is stable in sense that it depends only on your schema, not JVM/time or date of creation.
On the other hand it depends on all fields in entity. If we have next n fields:
typeName_1 fieldName_1;
typeName_2 fieldName_2;
&#8230;
typeName_n fieldName_n;we could calculate
serialVersionUID =
(fieldName_1.hashCode() XOR typeName_1.hashCode()) * 31^0+
(fieldName_2.hashCode() XOR typeName_2.hashCode()) [...]]]></description>
			<content:encoded><![CDATA[<p><font class="postbody">Here is some way of generating serialVersionUID for java entities.<br />
It is stable in sense that it depends only on your schema, not JVM/time or date of creation.<br />
On the other hand it depends on all fields in entity.</font><font class="postbody"> If we have next <font style="font-style: italic">n</font> fields:<br />
typeName_1 fieldName_1;<br />
typeName_2 fieldName_2;<br />
&#8230;<br />
typeName_n fieldName_n;</font><font class="postbody">we could calculate<br />
<font class="postbody">serialVersionUID =<br />
(fieldName_1.hashCode() XOR typeName_1.hashCode()) * 31^0+<br />
(fieldName_2.hashCode() XOR typeName_2.hashCode()) * 31^1 + &#8230; +<br />
(fieldName_n.hashCode() XOR typeName_n.hashCode()) * 31^n</font><font class="postbody"> </font><font class="postbody">where fieldName_i.hashCode() is hashCode() of fieldName_i string<br />
(for int id; it will be &#8220;id&#8221;.hashCode())<br />
and typeName_i.hashCode() is hashCode() of typeName_i string<br />
(for int id; it will be &#8220;int&#8221;.hashCode())</font><font class="postbody">so, we will be independent from<br />
1) JVM<br />
2) time/date of creation<br />
and depend on<br />
<font class="postbody">1) fields order<br />
</font><font class="postbody">2) field types<br />
3) field names </font></font></font></p>
]]></content:encoded>
			<wfw:commentRss>http://artemgolubev.com/algorithm-for-generating-serialversionuid-for-java-entities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
