<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: An Easier Java ORM</title>
	<atom:link href="http://www.codecommit.com/blog/java/an-easier-java-orm/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/java/an-easier-java-orm</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:21:24 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2593</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Fri, 21 Dec 2007 05:17:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2593</guid>
		<description>@Cristian

Pre-0.7 (the soon-to-be-released version in the SVN) enum storage wasn&#039;t possible using the vanilla distribution.  The extensible type system of course allowed for such a mapping to be trivially implemented (and that is how it is now done in the core), but previously it was not available &quot;out of the box&quot;.

After much wrestling with the pros and cons, the decision was made to use the ordinal value of the enum, rather than the String name.  This obviously makes it slightly less readable on the database, but it allows for trivial name-refactorings without breaking database integrity.  Thus, the corresponding type for enum is INTEGER.

Perhaps down the road AO will support database-specific type implementations like MySQL&#039;s ENUM, but at the moment this too must be done outside of the core (possible, but not implemented).</description>
		<content:encoded><![CDATA[<p>@Cristian</p>
<p>Pre-0.7 (the soon-to-be-released version in the SVN) enum storage wasn&#8217;t possible using the vanilla distribution.  The extensible type system of course allowed for such a mapping to be trivially implemented (and that is how it is now done in the core), but previously it was not available &#8220;out of the box&#8221;.</p>
<p>After much wrestling with the pros and cons, the decision was made to use the ordinal value of the enum, rather than the String name.  This obviously makes it slightly less readable on the database, but it allows for trivial name-refactorings without breaking database integrity.  Thus, the corresponding type for enum is INTEGER.</p>
<p>Perhaps down the road AO will support database-specific type implementations like MySQL&#8217;s ENUM, but at the moment this too must be done outside of the core (possible, but not implemented).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cristian Gary</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2592</link>
		<dc:creator>Cristian Gary</dc:creator>
		<pubDate>Fri, 21 Dec 2007 02:09:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2592</guid>
		<description>I , nice work.  
I  have a doubt.  
how you can identifi a Enum java type into SQL type?</description>
		<content:encoded><![CDATA[<p>I , nice work.<br />
I  have a doubt.<br />
how you can identifi a Enum java type into SQL type?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ynw</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2148</link>
		<dc:creator>ynw</dc:creator>
		<pubDate>Tue, 28 Aug 2007 10:36:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2148</guid>
		<description>Here comes another project to check</description>
		<content:encoded><![CDATA[<p>Here comes another project to check</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2082</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Thu, 19 Jul 2007 23:37:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2082</guid>
		<description>Well, I&#039;ll grant you that boiler-plate POJO vs Proxy is probably about equal.  I suppose at some minimal level, the compiler still has to be satisfied.  And as pointed out earlier, the POJO approach has the major advantage in that all getters and setters can be generated from fields.

AO actually doesn&#039;t have it&#039;s own query syntax.  It&#039;s just using PreparedStatement fragments.  For the example you gave, the fragment of &quot;query text&quot; is actually concatenated directly into an SQL query, like so:  &quot;SELECT id FROM person WHERE ${query_text}&quot;, and then executed with the specified parameters.  I didn&#039;t look, does BK actually use PreparedStatements?  And if so, how effectively?  This is a really important issue, especially for databases like Derby or Oracle which rely heavily on PS and have lousy performance without them.

Point taken on the SELECT * vs lazy load.  Actually, it&#039;s possible in AO to do this sort of thing (I added the functionality like two weeks ago, so like most things it isn&#039;t documented yet).  The code would look something like this:

manager.find(Person.class, Query.select(&quot;*&quot;).where(&quot;name LIKE ? OR age &gt; ?&quot;, &quot;Joe&quot;, 9));

Query is just a preparedstatement builder class which allows things like: Query.select().where(&quot;name = ?&quot;, &quot;Bill&quot;).limit(5).order(&quot;name&quot;) =&gt; &quot;SELECT id FROM ${table_name} WHERE name = ? ORDER BY name LIMIT 5&quot;.  The idea behind it is that it mimics the ActiveRecord find() syntax a bit, through the filter that Java doesn&#039;t have symbols like Ruby.</description>
		<content:encoded><![CDATA[<p>Well, I&#8217;ll grant you that boiler-plate POJO vs Proxy is probably about equal.  I suppose at some minimal level, the compiler still has to be satisfied.  And as pointed out earlier, the POJO approach has the major advantage in that all getters and setters can be generated from fields.</p>
<p>AO actually doesn&#8217;t have it&#8217;s own query syntax.  It&#8217;s just using PreparedStatement fragments.  For the example you gave, the fragment of &#8220;query text&#8221; is actually concatenated directly into an SQL query, like so:  &#8220;SELECT id FROM person WHERE ${query_text}&#8221;, and then executed with the specified parameters.  I didn&#8217;t look, does BK actually use PreparedStatements?  And if so, how effectively?  This is a really important issue, especially for databases like Derby or Oracle which rely heavily on PS and have lousy performance without them.</p>
<p>Point taken on the SELECT * vs lazy load.  Actually, it&#8217;s possible in AO to do this sort of thing (I added the functionality like two weeks ago, so like most things it isn&#8217;t documented yet).  The code would look something like this:</p>
<p>manager.find(Person.class, Query.select(&#8220;*&#8221;).where(&#8220;name LIKE ? OR age &gt; ?&#8221;, &#8220;Joe&#8221;, 9));</p>
<p>Query is just a preparedstatement builder class which allows things like: Query.select().where(&#8220;name = ?&#8221;, &#8220;Bill&#8221;).limit(5).order(&#8220;name&#8221;) =&gt; &#8220;SELECT id FROM ${table_name} WHERE name = ? ORDER BY name LIMIT 5&#8243;.  The idea behind it is that it mimics the ActiveRecord find() syntax a bit, through the filter that Java doesn&#8217;t have symbols like Ruby.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2081</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Thu, 19 Jul 2007 22:29:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2081</guid>
		<description>Thanks for the response. Regarding your comments:

*** Still requires a lot of boiler-plate code (it’s POJO based)

I may be misunderstanding something here. In BeanKeeper your class definition would be:

public class Person {
    private String firstName;
    public String getFirstName() { return firstName; }
    public void setFirstName(String firstName) { this.firstName = firstName; }
}

In ActiveObjects your class (interface) definition would be:

public interface Person extends Entity {
    public String getFirstName();
    public void setFirstName(String firstName);
}

So, by &quot;boilerplate code&quot;, are you referring to the implementation of the getters and setters? I suppose it is a bit of extra code, but at the same time, being able to use POJOs like this gains you a lot of flexibility:

- You can easily add custom code to your getters and setters
- Works well to persist existing/legacy classes
- External users of your entity classes do not have know or care about the persistence manager, they just create and use POJOs like any other object

I suppose the above may just be general benefits of doing things the POJO way. Anyway, for my particular project, the above points were quite important - I&#039;m sure there are cases where they are not as important (e.g. starting a new project from scratch).

*** Has it’s own query syntax (HQL is a big reason I avoid Hibernate)

Doesn&#039;t AO have its own query syntax too? BeanKeeper queries don&#039;t seem all that different from AO queries to me, for example:

manager.find(Person.class, &quot;name LIKE ? OR age &gt; ?&quot;, &quot;Joe&quot;, 9); // AO
store.find(&quot;find person where name LIKE &#039;Joe&#039; OR age &gt; 9&quot;); // BK

*** Seems to be List based for relations, rather than the more intuitive (and performant) array based

BeanKeeper&#039;s lazy lists are actually the primary reason I used the library for a previous project - you can execute queries that return huge lists with very low memory usage. By using the List interface instead of arrays, BeanKeeper can page objects into memory only when they are actually accessed. This sort of feature is really useful for reporting, where you may be dealing with queries that return hundreds of thousands of objects.

BTW, what is the reason that arrays are more intuitive? Doesn&#039;t everyone these days use Collections instead of arrays (unless you&#039;re doing some low-level stuff)? Regarding performance, it seems unlikely that there would be any noticeable difference between using arrays and Lists for an ORM library.

*** In ActiveObjects, every value is lazy-loaded and cached. So you use a minimal amount of memory for each entity.

Agreed, this is a benefit of using an interface and not a POJO. On the other hand, if you do need to access all the data in an object, it is more efficient to do a single SELECT * than to execute many smaller queries. The memory use of a single object does not typically cause too many problems - it&#039;s normally only when you have thousands of objects in memory at the same time, and the BeanKeeper lazy lists address this issue quite well.

I&#039;m definitely looking forward to trying out ActiveObjects soon. I have a few small BeanKeeper test programs, so it&#039;ll be interesting to re-implement them with ActiveObjects and compare the code and results.</description>
		<content:encoded><![CDATA[<p>Thanks for the response. Regarding your comments:</p>
<p>*** Still requires a lot of boiler-plate code (it’s POJO based)</p>
<p>I may be misunderstanding something here. In BeanKeeper your class definition would be:</p>
<p>public class Person {<br />
    private String firstName;<br />
    public String getFirstName() { return firstName; }<br />
    public void setFirstName(String firstName) { this.firstName = firstName; }<br />
}</p>
<p>In ActiveObjects your class (interface) definition would be:</p>
<p>public interface Person extends Entity {<br />
    public String getFirstName();<br />
    public void setFirstName(String firstName);<br />
}</p>
<p>So, by &#8220;boilerplate code&#8221;, are you referring to the implementation of the getters and setters? I suppose it is a bit of extra code, but at the same time, being able to use POJOs like this gains you a lot of flexibility:</p>
<p>- You can easily add custom code to your getters and setters<br />
- Works well to persist existing/legacy classes<br />
- External users of your entity classes do not have know or care about the persistence manager, they just create and use POJOs like any other object</p>
<p>I suppose the above may just be general benefits of doing things the POJO way. Anyway, for my particular project, the above points were quite important &#8211; I&#8217;m sure there are cases where they are not as important (e.g. starting a new project from scratch).</p>
<p>*** Has it’s own query syntax (HQL is a big reason I avoid Hibernate)</p>
<p>Doesn&#8217;t AO have its own query syntax too? BeanKeeper queries don&#8217;t seem all that different from AO queries to me, for example:</p>
<p>manager.find(Person.class, &#8220;name LIKE ? OR age &gt; ?&#8221;, &#8220;Joe&#8221;, 9); // AO<br />
store.find(&#8220;find person where name LIKE &#8216;Joe&#8217; OR age &gt; 9&#8243;); // BK</p>
<p>*** Seems to be List based for relations, rather than the more intuitive (and performant) array based</p>
<p>BeanKeeper&#8217;s lazy lists are actually the primary reason I used the library for a previous project &#8211; you can execute queries that return huge lists with very low memory usage. By using the List interface instead of arrays, BeanKeeper can page objects into memory only when they are actually accessed. This sort of feature is really useful for reporting, where you may be dealing with queries that return hundreds of thousands of objects.</p>
<p>BTW, what is the reason that arrays are more intuitive? Doesn&#8217;t everyone these days use Collections instead of arrays (unless you&#8217;re doing some low-level stuff)? Regarding performance, it seems unlikely that there would be any noticeable difference between using arrays and Lists for an ORM library.</p>
<p>*** In ActiveObjects, every value is lazy-loaded and cached. So you use a minimal amount of memory for each entity.</p>
<p>Agreed, this is a benefit of using an interface and not a POJO. On the other hand, if you do need to access all the data in an object, it is more efficient to do a single SELECT * than to execute many smaller queries. The memory use of a single object does not typically cause too many problems &#8211; it&#8217;s normally only when you have thousands of objects in memory at the same time, and the BeanKeeper lazy lists address this issue quite well.</p>
<p>I&#8217;m definitely looking forward to trying out ActiveObjects soon. I have a few small BeanKeeper test programs, so it&#8217;ll be interesting to re-implement them with ActiveObjects and compare the code and results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2080</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Thu, 19 Jul 2007 19:26:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2080</guid>
		<description>@Daniel

No, I wasn&#039;t familiar with it actually.  It does seem interesting though.  My three problems with it just from reading bits of the tutorial:

 * Still requires a lot of boiler-plate code (it&#039;s POJO based)
 * Has it&#039;s own query syntax (HQL is a big reason I avoid Hibernate)
 * Seems to be List based for relations, rather than the more intuitive (and performant) array based

The problem with POJO-based frameworks, beyond the added boiler-plate, is that everything must be eagerly loaded.  Basically, you turn every entity retrieval call into a SELECT *  Hibernate can get around this with bytecode manipulation, but personally I&#039;m a little leery of letting random frameworks peer into my class internals.

In ActiveObjects, every value is lazy-loaded and cached.  So you use a minimal amount of memory for each entity.</description>
		<content:encoded><![CDATA[<p>@Daniel</p>
<p>No, I wasn&#8217;t familiar with it actually.  It does seem interesting though.  My three problems with it just from reading bits of the tutorial:</p>
<p> * Still requires a lot of boiler-plate code (it&#8217;s POJO based)<br />
 * Has it&#8217;s own query syntax (HQL is a big reason I avoid Hibernate)<br />
 * Seems to be List based for relations, rather than the more intuitive (and performant) array based</p>
<p>The problem with POJO-based frameworks, beyond the added boiler-plate, is that everything must be eagerly loaded.  Basically, you turn every entity retrieval call into a SELECT *  Hibernate can get around this with bytecode manipulation, but personally I&#8217;m a little leery of letting random frameworks peer into my class internals.</p>
<p>In ActiveObjects, every value is lazy-loaded and cached.  So you use a minimal amount of memory for each entity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2079</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Thu, 19 Jul 2007 18:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2079</guid>
		<description>Have you taken a look at BeanKeeper before?

http://www.netmind.hu/persistence/

It&#039;s another persistence library with a similar philosophy - zero configuration, no boilerplate code, no administration, etc. I&#039;ve used it a bit in the past, and it&#039;s really quite cool how it magically stores and loads objects without any ugly ORM code or configuration. If you are familiar with it, what would you say are main advantages of ActiveObjects over BeanKeeper?</description>
		<content:encoded><![CDATA[<p>Have you taken a look at BeanKeeper before?</p>
<p><a href="http://www.netmind.hu/persistence/" rel="nofollow">http://www.netmind.hu/persistence/</a></p>
<p>It&#8217;s another persistence library with a similar philosophy &#8211; zero configuration, no boilerplate code, no administration, etc. I&#8217;ve used it a bit in the past, and it&#8217;s really quite cool how it magically stores and loads objects without any ugly ORM code or configuration. If you are familiar with it, what would you say are main advantages of ActiveObjects over BeanKeeper?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2078</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Wed, 18 Jul 2007 21:52:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2078</guid>
		<description>@richard

Well, you&#039;ve got two choices for the example you gave.  You can define the database schema attributes to not allow nulls in the houseID field:

public interface Person extends Entity {
   // ...

   @NotNull
   public House getHouse();
   @NotNull
   public void setHouse(House house);
}

Or for a more complex rule, you could use AO implementations, which are definitely weird, but quite powerful.  I&#039;ll make sure I cover them in a future post.

@Eelco

I&#039;ll take a look at those wicket sources.  Since I&#039;m working on a project using Wicket and ActiveObjects, it&#039;d obviously be nice to make the integration as tight as possible.

I&#039;ll have to look at cglib and similar.  I briefly considered byte-code manipulation when designing the framework, but that always required weird hacks like custom classloaders etc...  While I don&#039;t have a problem writing framework internals which do weird stuff, I don&#039;t want the API to be too bizarre.  :-)</description>
		<content:encoded><![CDATA[<p>@richard</p>
<p>Well, you&#8217;ve got two choices for the example you gave.  You can define the database schema attributes to not allow nulls in the houseID field:</p>
<p>public interface Person extends Entity {<br />
   // &#8230;</p>
<p>   @NotNull<br />
   public House getHouse();<br />
   @NotNull<br />
   public void setHouse(House house);<br />
}</p>
<p>Or for a more complex rule, you could use AO implementations, which are definitely weird, but quite powerful.  I&#8217;ll make sure I cover them in a future post.</p>
<p>@Eelco</p>
<p>I&#8217;ll take a look at those wicket sources.  Since I&#8217;m working on a project using Wicket and ActiveObjects, it&#8217;d obviously be nice to make the integration as tight as possible.</p>
<p>I&#8217;ll have to look at cglib and similar.  I briefly considered byte-code manipulation when designing the framework, but that always required weird hacks like custom classloaders etc&#8230;  While I don&#8217;t have a problem writing framework internals which do weird stuff, I don&#8217;t want the API to be too bizarre.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eelco Hillenius</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2077</link>
		<dc:creator>Eelco Hillenius</dc:creator>
		<pubDate>Wed, 18 Jul 2007 21:43:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2077</guid>
		<description>Sorry for spamming, but another thing to look at - if you&#039;re interested - is the phonebook example (http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-phonebook). That&#039;s an example project that shows how you *could* use Hibernate, Shades or iBatis with Wicket. And maybe ActiveObjects sometime as well :)

Drop me a line if you want write access to wicket-stuff.</description>
		<content:encoded><![CDATA[<p>Sorry for spamming, but another thing to look at &#8211; if you&#8217;re interested &#8211; is the phonebook example (<a href="http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-phonebook" rel="nofollow">http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-phonebook</a>). That&#8217;s an example project that shows how you *could* use Hibernate, Shades or iBatis with Wicket. And maybe ActiveObjects sometime as well <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Drop me a line if you want write access to wicket-stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eelco Hillenius</title>
		<link>http://www.codecommit.com/blog/java/an-easier-java-orm/comment-page-1#comment-2076</link>
		<dc:creator>Eelco Hillenius</dc:creator>
		<pubDate>Wed, 18 Jul 2007 21:37:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.danielspiewak.com/java/an-easier-java-orm#comment-2076</guid>
		<description>Maybe Databinder (http://databinder.net/site/show/overview) is something to look at when thinking about an integration project. I&#039;m not sure either. But as you&#039;re trying to cut the ammount of code you need to write, it probably should provide some very convenient models and transaction utilities.</description>
		<content:encoded><![CDATA[<p>Maybe Databinder (<a href="http://databinder.net/site/show/overview" rel="nofollow">http://databinder.net/site/show/overview</a>) is something to look at when thinking about an integration project. I&#8217;m not sure either. But as you&#8217;re trying to cut the ammount of code you need to write, it probably should provide some very convenient models and transaction utilities.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

