<?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>Blog @ SIB Visions &#187; JPA</title>
	<atom:link href="http://blog.sibvisions.com/tag/jpa/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sibvisions.com</link>
	<description>Blog @ SIB Visions</description>
	<lastBuildDate>Mon, 30 Mar 2026 11:14:36 +0000</lastBuildDate>
		<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JVxEE 1.2</title>
		<link>https://blog.sibvisions.com/2015/09/18/jvxee-1-2/</link>
		<comments>https://blog.sibvisions.com/2015/09/18/jvxee-1-2/#comments</comments>
		<pubDate>Fri, 18 Sep 2015 15:19:03 +0000</pubDate>
		<dc:creator>rzenz</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Release notes]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JVx]]></category>
		<category><![CDATA[JVxEE]]></category>

		<guid isPermaLink="false">http://blog.sibvisions.com/?p=4992</guid>
		<description><![CDATA[JVxEE version 1.2 is out...]]></description>
			<content:encoded><![CDATA[<p><b>JVxEE version 1.2 is out</b>!</p>
<h3 style="padding-top: 15px">The good news</h3>
<p>JVxEE is now available from Maven central, that means that you can add it as dependency to your Maven projects:</p>
<div class="codesnip-container" >
<div class="xml codesnip" style="font-family:monospace;"><span class="sc3"><span class="re1">&lt;dependency<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;groupId<span class="re2">&gt;</span></span></span>com.sibvisions.jvx<span class="sc3"><span class="re1">&lt;/groupId<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;artifactId<span class="re2">&gt;</span></span></span>jvxee<span class="sc3"><span class="re1">&lt;/artifactId<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;version<span class="re2">&gt;</span></span></span>1.2<span class="sc3"><span class="re1">&lt;/version<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/dependency<span class="re2">&gt;</span></span></span></div>
</div>
<p>The first of the two major changes are that we fixed possible exceptions that might be thrown by JPAStorage.getEstimatedRowCount(ICondition), it should now work under all situations.</p>
<p>The second change is the handling of foreign key columns. Previously, foreign key columns where named with the pattern "REFERENCEDTABLE_REFERENCEDCOLUMN", which can lead to collisions if there is more than one column referencing the same table and primary key. So it was possible that you would end up with two columns with the same name, which of course can't be handled by the storage and databook correctly. We devised a new naming scheme and from now on the foreign key columns are named with a combination of the referencing column and the referenced column.</p>
<p>An example:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">@<span class="kw3">Entity</span> <span class="kw1">public</span> <span class="kw1">class</span> A <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; @Id <span class="kw1">private</span> <span class="kw4">int</span> id<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> B source<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> B target<span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Getters/Setters</span><br />
<span class="br0">&#125;</span></p>
<p>@<span class="kw3">Entity</span> <span class="kw1">public</span> <span class="kw1">class</span> B <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; @Id <span class="kw1">private</span> <span class="kw4">int</span> id<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> name<span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <span class="co1">// Getters/Setters</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>With 1.1 the generated columns would look like this, for entity "A":</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">BigDecimal</span><br />
B_ID &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">BigDecimal</span><br />
B_NAME &nbsp; &nbsp; &nbsp;<span class="kw3">String</span><br />
B_ID &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">BigDecimal</span><br />
B_NAME &nbsp; &nbsp; &nbsp;<span class="kw3">String</span></div>
</div>
<p>And with 1.2:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">BigDecimal</span><br />
SOURCE_ID &nbsp; <span class="kw3">BigDecimal</span><br />
SOURCE_NAME <span class="kw3">String</span><br />
TARGET_ID &nbsp; <span class="kw3">BigDecimal</span><br />
TARGET_NAME <span class="kw3">BigDecimal</span></div>
</div>
<p>This is definitely an improvement!</p>
<h3 style="padding-top: 15px">The bad news</h3>
<p>There is always a downside <img src='https://blog.sibvisions.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>The changes in the foreign key column naming scheme, to avoid collisions, also mean that most foreign key columns do now have a different name. You'll have to check your code for usages of the now differently named columns. </p>
<p>But there is also an upside! With <a href="http://www.sibvisions.com/eplug">EPlug you will find those easily</a>.</p>
<h3 style="padding-top: 15px">Usage example</h3>
<p>JVxEE provides the possibility to utilize the Java Persistence API (JPA) as backend for storages and databooks. JPA is powered by POJOs, like these:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">@<span class="kw3">Entity</span> <span class="kw1">public</span> <span class="kw1">class</span> Aircraft <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> country<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> description<span class="sy0">;</span><br />
&nbsp; &nbsp; @Id @OneToMany <span class="kw1">private</span> <span class="kw3">String</span> registrationNumber<span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p>@<span class="kw3">Entity</span> <span class="kw1">public</span> <span class="kw1">class</span> Airport <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; @Id @OneToMany <span class="kw1">private</span> <span class="kw3">String</span> code<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> country<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> location<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> name<span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p>@<span class="kw3">Entity</span> <span class="kw1">public</span> <span class="kw1">class</span> Flight <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; @OneToOne <span class="kw1">private</span> Aircraft aircraft<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw3">String</span> airline<span class="sy0">;</span><br />
&nbsp; &nbsp; @OneToOne <span class="kw1">private</span> Airport airportDestination<span class="sy0">;</span><br />
&nbsp; &nbsp; @OneToOne <span class="kw1">private</span> Airport airportOrigin<span class="sy0">;</span><br />
&nbsp; &nbsp; @Id <span class="kw1">private</span> <span class="kw3">String</span> flightNumber<span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>This is an extremely simplified model for airline flights. </p>
<p>There is an aircraft that can be used, airports that can be flown to and from and the flight itself. Flight is referencing both, the aircraft and the airport. Now we only need to tell JPA about these classes by placing a persistence.xml in the META-INF directory, like this one that we use for our unit tests:</p>
<div class="codesnip-container" >
<div class="xml codesnip" style="font-family:monospace;"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span> <span class="re2">?&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;persistence</span> <span class="re0">xmlns:xsi</span>=<span class="st0">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">xsi:schemaLocation</span>=<span class="st0">&quot;http://java.sun.com/xml/ns/persistence &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">version</span>=<span class="st0">&quot;2.0&quot;</span> <span class="re0">xmlns</span>=<span class="st0">&quot;http://java.sun.com/xml/ns/persistence&quot;</span><span class="re2">&gt;</span></span></p>
<p>&nbsp; <span class="sc3"><span class="re1">&lt;persistence-unit</span> <span class="re0">name</span>=<span class="st0">&quot;test&quot;</span> <span class="re0">transaction-type</span>=<span class="st0">&quot;RESOURCE_LOCAL&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;class<span class="re2">&gt;</span></span></span>com.sibvisions.rad.persist.jpa.entity.flight.Aircraft<span class="sc3"><span class="re1">&lt;/class<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;class<span class="re2">&gt;</span></span></span>com.sibvisions.rad.persist.jpa.entity.flight.Airport<span class="sc3"><span class="re1">&lt;/class<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;class<span class="re2">&gt;</span></span></span>com.sibvisions.rad.persist.jpa.entity.flight.Flight<span class="sc3"><span class="re1">&lt;/class<span class="re2">&gt;</span></span></span></p>
<p>&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;properties<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;javax.persistence.jdbc.driver&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;org.hsqldb.jdbcDriver&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;javax.persistence.jdbc.url&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;jdbc:hsqldb:hsql://localhost/db&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;javax.persistence.jdbc.user&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;sa&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;javax.persistence.jdbc.password&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;&quot;</span> <span class="re2">/&gt;</span></span></p>
<p>&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;eclipselink.ddl-generation&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;drop-and-create-tables&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;eclipselink.ddl-generation.output-mode&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;database&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;eclipselink.logging.level&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;FINE&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/properties<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/persistence-unit<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/persistence<span class="re2">&gt;</span></span></span></div>
</div>
<p><i>(Sure, it's also possible without manual XML mapping)</i></p>
<p>Now all that is left is creating a new storage that uses the JPA:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">EntityManagerFactory entityManagerFactory <span class="sy0">=</span> Persistence.<span class="me1">createEntityManagerFactory</span><span class="br0">&#40;</span><span class="st0">&quot;test&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
EntityManager entityManager <span class="sy0">=</span> entityManagerFactory.<span class="me1">createEntityManager</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>JPAStorage storage <span class="sy0">=</span> <span class="kw1">new</span> JPAStorage<span class="br0">&#40;</span>Flight.<span class="kw1">class</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
storage.<span class="me1">setEntityManager</span><span class="br0">&#40;</span>entityManager<span class="br0">&#41;</span><span class="sy0">;</span><br />
storage.<span class="me1">open</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>And that's it! From here on there is only JVx code.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.sibvisions.com/2015/09/18/jvxee-1-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
