<?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>Developers, Developers, Developers! &#187; JPA</title>
	<atom:link href="http://maksim.sorokin.dk/it/tag/jpa/feed/" rel="self" type="application/rss+xml" />
	<link>http://maksim.sorokin.dk/it</link>
	<description>Maksim Sorokin IT Blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:37:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Compound Key In JPA</title>
		<link>http://maksim.sorokin.dk/it/2010/03/26/compound-key-in-jpa/</link>
		<comments>http://maksim.sorokin.dk/it/2010/03/26/compound-key-in-jpa/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 17:08:05 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE 6]]></category>
		<category><![CDATA[JPA]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=120</guid>
		<description><![CDATA[Sometimes one needs a compound key for specifying @Entity. TopLink website says that one should provide multiple @Id and @IdClass for a composite primary key. But it actually works without specifing @IdClass too. For example if we have a Pencil with a composite key consisting of color and thickness: import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes one needs a compound key for specifying <a href="http://java.sun.com/javaee/6/docs/api/"><code>@Entity</code></a>. TopLink website <a href="http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#Id">says</a> that one should provide multiple <code>@Id</code> and </code>@IdClass</code> for a composite primary key. But it actually works without specifing <code>@IdClass</code> too.<br />
<span id="more-120"></span></p>
<p>For example if we have a Pencil with a composite key consisting of <code>color</code> and <code>thickness</code>:</p>
<pre class="brush: java; title: ;">
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = &quot;pencils&quot;)
public class Pencil {

  @Id
  @Column(name = &quot;color&quot;)
  private String color;

  @Id
  @Column(name = &quot;thickness&quot;)
  private String thickness;

  ...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/03/26/compound-key-in-jpa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

