<?xml version="1.0"?>

<rss version="2.0">
  <channel>
    <title>Andrew Cowie</title>
    <link>http://research.operationaldynamics.com/blogs/andrew/software/db4o/</link>
    <description>Blog postings by Andrew Cowie about Open Source
and Software Development. This section is about my experiences with db4o,
an object oriented, embedded database engine which persists Java objects.</description>
    <language>en</language>
    <copyright>Copyright (c) 2008 Operational Dynamics Consulting Pty Ltd. All rights reserved. Not for redistribution or attribution without permission in writing.</copyright>

    <image>
      <url>http://research.operationaldynamics.com/images/andrew_Hackergotchi.png</url>
      <title>Operational Dynamics Research</title>
      <link>http://research.operationaldynamics.com/blogs/andrew/software/db4o/</link>
      <width>80</width>
      <height>86</height>
    </image>

    <lastBuildDate>Tue, 18 Nov 2008 01:36:00 GMT</lastBuildDate>

    <item>
      <title>On the politics and economics of dual-licencing</title>
      <link>http://research.operationaldynamics.com/blogs/andrew/software/db4o/free-riding.html</link>
      <description><![CDATA[<h2>Christof on free-loaders</h2>

<p>In a recent thread on <a href="http://developer.db4o.com/"><code>developer.db4o.com</code></a>, several people were whining about how the GPL is too tough for them, and that they wanted <strong><code>db4o</code></strong> for free without neither the obligations of mutual software freedom nor the requirement to have to pay for a commercial licence.</p>

<p>Midway through, <a href="http://developer.db4o.com/blogs/christof/">Christof Wittig</a>, their CEO, posted a <a href="http://developer.db4o.com/forums/post/30979.aspx">reply</a> that I thought really captured the essence of what they are doing as a company. Here&#8217;s my favourite part:</p>

<blockquote>
  <p>I think most of you know that db4o is a dual-licensed product &#8212; with [the same code available in] an open source version and a commercial version.  The commercial version is distributed by db4objects, a company that is for-profit and &#8212; believe it or not &#8212; we are here to make money. </p>
  
  <p>If you are open source/GPL, we are.  If you don&#8217;t want to comply with the GPL, we&#8217;re not open source and not free either &#8212; in this case we&#8217;re as commercial as you are, though perhaps a little bit more affordable than others.  It is as simple as this. </p>
  
  <p>All discussions on this topic are usually by people who want to use the free/open source versions for their commercial/closed source businesses without giving back to the community &#8212; either with code or with money.  For me that&#8217;s just free-riding.</p>
</blockquote>

<h2>The forbearance of CEOs</h2>

<p>It never ceases to amaze me what the CEOs go through. Running any company means endlessly answering the same questions, and I can only imagine what the clamour must be like for the CEO of an open source software company. Under that sort of constant barrage, it&#8217;s all the more impressive that someone like Christof continues to keep such an even keel. Well mostly&#8230;</p>

<blockquote>
  <p>Some of you use the value-approach for pricing (which we promote, too:  Usually we try to capture 3-5% of your software value).  Some claim, though, that a few thousand bucks [that would be db4o&#8217;s licence cost] would be 50% of their total cost.  If this was right, then the entire business was only 2&#215; a few thousand dollars.  But how can this be? Even if you live in Siberia, you cannot make a living on this as a company.  So you are either not saying the truth or, more likely, you exclude complementary revenue streams, e.g. from services or add-ons, that you cross-subsidize with low cost or free software.  These revenue streams, though, should be included in your value approach, and then you&#8217;ll soon find yourself in the low digit ballpark with the db4o license fees.</p>
</blockquote>

<p>Or you can release your own software under the GPL. Take your pick.</p>

<h2>Why Open Source is not communism</h2>

<p>I advise clients about Open Source, and one of the questions that inevitably comes up in the discussion about people who dual-licence their software is, <em>&#8220;but it&#8217;s GPL! How dare they charge for it! How can they? <code>%#@&#036;^&amp;!</code>&#8221;</em> Sadly, the people asking that question in such an arrogant and demanding tone have missed the point. Open Source is not communism! There is no obligation to contribute what you own and no one taking it from you by force, stealing it for their own benefit while justifying their actions in the Holy Name of the People.</p>

<p><em>&#8220;No,&#8221;</em> replies the author, <em>&#8220;It&#8217;s <strong>my property</strong>. I wrote it. I have the copyright on it, I own it. I can do whatever I like with it. I have <strong>chosen</strong> to release my code, without patent encumberment, and you can use it, <strong>but only under very strict conditions</strong>.</em> If you&#8217;re willing to agree to those limitations and in so doing contribute to the raising up of the whole world through the apotheosis of software freedom, then you&#8217;re welcome to use their code for whatever you&#8217;d like. People and organizations who have chosen the dual-licence model to fund their enterprise then say, <em>&#8220;Not willing to meet the terms the GPL? Then if you want a licence to use my property in your product, start forking over the cash.&#8221;</em></p>

<p>One way or the other, FOSS is about contribution. Don&#8217;t whine about why you can&#8217;t have it for nothing.</p>

<p>AfC</p>
]]></description>
      <author>andrew@operationaldynamics.com (Andrew Cowie)</author>
      <category>/andrew/software/db4o</category>
      <pubDate>Wed, 13 Dec 2006 00:48:00 GMT</pubDate>
      <guid isPermaLink="false">free-riding</guid>
    </item>

    <item>
      <title>db4o developers open their conference call</title>
      <link>http://research.operationaldynamics.com/blogs/andrew/software/db4o/developer-conference-call.html</link>
      <description><![CDATA[<p>We like to go on and on about the benefits of open source, but its still rare to see a company bet everything on the premise. That&#8217;s one of the reasons that db4objects, maker of the <a href="http://www.db4objects.com/"><code>db4o</code></a> object oriented database, continues to impress me.</p>

<p>Those of us heavily involved in <em>mondial libr&eacute;</em> take it for granted that our best work happens when we carry it out in an environment of openness and honesty. Few companies, however, even ones who release their code under an open source licence, truly embrace this idea and continue the bulk of their activities in secret.</p>

<p>So this week I was really impressed to see the developers of <code>db4o</code> invite a semi-public audience to their weekly conference call. They&#8217;re still feeling their way (which is why they started with a limited group) but this is a company determined to do things better &#8212; db4objects has already made the web forums their developers use to communicate public, then went one further and granted privileges to some of their more involved community members to contribute as well.</p>

<p>One of my colleagues <a href="http://db4o.blogspot.com/2006/09/db4o-matter-of-trust.html">noted</a>:</p>

<blockquote>
  <p>It makes me feel good to listen to the people who are developing the database of my choice, because a database isn&#8217;t just software, a database is trustware! And it needs a big amount of trust to drop data into such an &#8220;exotic&#8221; and &#8220;small&#8221; object-database like db4o &#8230; but they seem to take the right approach: by open-sourcing their database and their development-model db4o gains lots of trust. And that&#8217;s what really counts in database-driven business.</p>
  
  <p><span style="font-style: normal; font-size: x-small;padding-left:200px;">&#8212; Maik Jablonski</span></p>
</blockquote>

<p>In a rational world, I&#8217;d like to think I have better things to do than sitting up until 03:00 in order to listen to a bunch of database hackers talk about what they&#8217;re working on. The exciting thing about open source, though, is that its about more than cold hard rationality &#8212; it&#8217;s about the fire and passion that drives people and it&#8217;s always terrific to spend time watching a talented team being creative as they hash out hard problems.</p>

<p>Nothing is ever easy: I imagine that in the future as the spotlight moves onto them the temptation will be to turn their conference call into a marketing event. If they can resist that and continue to have frank discussions about contentious topics in the open, then I think they will have taken a significant step forward. Indeed, having their meeting in a more public forum will force them to stay on topic and use their time wisely, and I think that&#8217;s useful in its own right.</p>

<p>AfC</p>

<!--
Over the summer, db4objects, Inc recognized a number of people who had been making significant contributions in their community, awarding them the title "db4o Most Valuable Professional" which is kind of fun.
-->
]]></description>
      <author>andrew@operationaldynamics.com (Andrew Cowie)</author>
      <category>/andrew/software/db4o</category>
      <pubDate>Thu, 28 Sep 2006 03:04:00 GMT</pubDate>
      <guid isPermaLink="false">developer-conference-call</guid>
    </item>

    <item>
      <title>db4object&#8217;s CEO in Sydney Wednesday</title>
      <link>http://research.operationaldynamics.com/blogs/andrew/software/db4o/christof-in-sydney.html</link>
      <description><![CDATA[<p>Christof Wittig, CEO of db4objects, Inc, maker of <a href="http://www.db4objects.com/"><code>db4o</code></a>, is in Sydney this week and he&#8217;ll be speaking at the Debian SIG of the Sydney Linux User&#8217;s Group (which is really just an extra chance for people to get together each month and have a few <a href="http://debian.slug.org.au/">drinks</a>), tomorrow night Wednesday 12 April 2006, at Cohi Bar, 359 Harbourside, Darling Harbour (the Pyrmont side), roughly 19:00-22:00, (starting after <a href="http://www.openskills.org/">Open Skills</a> finish their AGM, which debsig is gatecrashing). It&#8217;s going to be a rather free form session but Christof is a good speaker. That he, a businessman, chose to GPL his company&#8217;s product makes an interesting story, and what some of his clients have been using <code>db4o</code> to do is pretty cool.</p>

<p>For those that have no idea what I&#8217;m talking about, or why I find it interesting, here&#8217;s a brief extract from a <a href="http://research.operationaldynamics.com/blogs/andrew/software/db4o/querying-collections-in-db4o.html">blog posting</a> I made four months ago:</p>

<blockquote>
  <p>I&#8217;ve been working for a while now with db4o, an object-oriented database. It&#8217;s native Java (ie you use it from and feed it Java objects, as opposed to translating to some third-party pseudo or meta object representation as most of the original OODBMSes required you to do). It does a really straight forward job of just persisting Plain Old Java Objects. No mucking around with bytecode enhancers (like JDO) and certainly none of the self-mutilation that goes with EJB. db4o has proved fairly easy to use once you wrap your head around the fact that instead of foreign keys you just use a plain old Java variable &#8230; because of course all variables (ok, instance fields) are references in Java. Neat.</p>
  
  <p>To say that I have been nervous about contemplating db4o would be an understatement &#8212; I have lots of experience with data evolution in enterprise settings and using a OODBMS rather than a more traditional RDBMS scares the heck out of me. On the other hand, db4o gives me almost totally transparent persistence and has certainly <strong>massively</strong> accelerated development by allowing me to have a functional persistence layer in one of my applications from the get-go rather than wasting eons fighting through the Object-Relational impedance mismatch. So all in all it&#8217;s been a very good experience. Thus far, anyway, db4o has proved to be reliable and robust. Of course, you have to <em>use</em> it properly&#8230;</p>
</blockquote>

<p>Most of the other Java people* I&#8217;ve introduced <code>db4o</code> to have, of course, at first greeted me with &#8220;<em>what the fuck</em>&#8221; but usually the next morning I get a ping saying &#8220;<em>hey, this is pretty good</em>&#8221;, so it would seem I&#8217;m not alone in appreciating this library. The fact that it&#8217;s GPL is fantastic, but more than that it is <strong>tiny</strong> &#8212; it&#8217;s only a 600kB jar! We just dropped it into the <code>lib/</code> directory of one of our (yes, GPL) projects and ship it there. <em>Ta-da</em>, a complete object persistence mechanism.  Given that Java is the platform I work on and that the resources we can devote to development are limited, having something like <code>db4o</code> to use has been great; the least I can do is mention them once in a while.</p>

<p>AfC</p>

<p><span style="font-size:small">
 * I&#8217;m a Java on Linux guy, right? [Actually, I&#8217;m a management consultant focusing on crisis management, but the systems side of what I do is advising people who run Linux enterprise platforms, especially ones running large and complex Java applications; and programming wise I write Java apps for Linux. (Yes, Linux only; I write to the Free Java platform and use <code>java-gnome</code> to get to <code>GTK</code> &#8212; I couldn&#8217;t care less if my work ever runs on Windows)]. So no need to tell me how my using Java is horribly wrong and that I should be using some 19th Generation Language instead <code>:)</code>
</span></p>
]]></description>
      <author>andrew@operationaldynamics.com (Andrew Cowie)</author>
      <category>/andrew/software/db4o</category>
      <pubDate>Tue, 11 Apr 2006 13:05:00 GMT</pubDate>
      <guid isPermaLink="false">christof-in-sydney</guid>
    </item>

    <item>
      <title>Querying through Collections in db4o</title>
      <link>http://research.operationaldynamics.com/blogs/andrew/software/db4o/querying-collections-in-db4o.html</link>
      <description><![CDATA[<h2>Background</h2>

<p>I&#8217;ve been working for a while now with <a href="http://www.db4objects.com/"><code>db4o</code></a>, an object-oriented database. It&#8217;s native Java (ie you use it from and feed it Java objects, as opposed to translating to some third-party pseudo or meta object representation as most of the original OODBMSes required you to do). It does a really straight forward job of just persisting Plain Old Java Objects. No mucking around with bytecode enhancers (like JDO) and certainly none of the self-mutilation that goes with EJB. db4o has proved fairly easy to use once you wrap your head around the fact that instead of foreign keys you just use a plain old Java variable &#8230; because of course all variables (ok, instance fields) are references in Java. Neat.</p>

<p>To say that I am nervous about contemplating db4o would be an understatement &#8212; I have lots of experience with data evolution in enterprise settings and using a OODBMS rather than a more traditional RDBMS scares the heck out of me. On the other hand, db4o gives me almost totally transparent persistence and has certainly <strong>massively</strong> accelerated development by allowing me to have a functional persistence layer in one of my applications from the get-go rather than wasting eons fighting through the Object-Relational impedance mismatch. So all in all it&#8217;s been a very good experience. Thus far, anyway, db4o has proved to be reliable and robust. Of course, you have to <em>use</em> it properly&#8230;</p>

<p>[I&#8217;m not worried about it loosing data so much as being worried about schema migration and being able to <strong>ensure</strong> I can always get my data out. <code>db4o</code> is actually pretty good about data upgrades across schema migration, but there are lots of good reasons why the SQL crowd have long asserted that loose coupling to data is a better idea and that abstracting data design and storage from domain layers is a good thing.  {shrug} I won&#8217;t be surprised if I end up switching to Hibernate and PostgreSQL, but in the mean time, I&#8217;ve been able to completely avoid the ORM nightmare, and that makes me rather happy. Will I trust db4o it to actually store accounting data when I go live? Eeek. We&#8217;ll see.]</p>

<p>Aside: <em>As it stands right now, I&#8217;ve deliberately architected things so that you have to talk to the application [think app server] to talk to the data. All the data integrity is in the domain objects layer. So the usual reasons to translate it into SQL (a. &#8220;so that other applications can work with it&#8221;, b. &#8220;because the data is already there and your app is secondary&#8221;, and c. &#8220;because that&#8217;s what an RDBMS is for &#8212; ensuring data integrity&#8221;) don&#8217;t apply. It&#8217;s like your local bank - the ATM talks to the enterprise application middleware and THAT and only that talks to the database. Customers don&#8217;t write SQL to get their account balance. Yes, that&#8217;s contrived, but more to the point application programmers at the bank don&#8217;t talk to the database either. They ask the app server for a finder to get them account objects, and get one handed to them which they can then operate on. The actual database is quite shielded from them, thank you very much &#8212; at which point I make the inference that since the nature of the datastore is transparent to the application writer anyway, it doesn&#8217;t much matter what mode that database is. Yes, I understand that RDBMSes do a perfectly good job of ensuring data integrity (in fact, some argue to me that it&#8217;s their only real job) but I&#8217;m a Java guy and that&#8217;s where I&#8217;ve got my application and data integrity logic at the moment. Which is why object persistence is of interest to me. The enduring reason to go to an RDBMS &#8212; to protect me from my own screwups &#8212; remains.</em></p>

<h2>Querying</h2>

<p>I&#8217;ve recently started writing some finders &#8212; things that would help me quickly look up [persisted] objects by some commonly used set of constraints. This week it was getting a specific <code>Ledger</code> given a fragment of a [parent] <code>Account</code> title and a fragment of the <code>Ledger</code> name. Right now <code>Account</code>s contain a <code>Set</code> of <code>Ledger</code> objects in a field called <code>ledgers</code>.</p>

<p><code>db4o</code> <em>does</em> query through Collections &#8212; transparently, in fact, but I had trouble descending through the Collection to constrain the result set to just members of the  class which was contained in that Collection. To search for the Ledger whose name is &#8220;At Cost&#8221; within an Account titled &#8220;Furniture&#8221; using some prototypes to constrain the searches:</p>

<pre><code>String title = "Furniture";
String name = "At Cost"
...
Query query = container.query();

Account a = new Account();
a.setTitle(title);
query.constrain(a);

Query subquery = query.descend("ledgers");

Ledger r = new Ledger();
r.setName(name);
subquery.constrain(r);

ObjectSet results = subquery.execute();
</code></pre>

<p>Returned me a single <code>LinkedHashSet</code>! That sorta makes sense given that the query node was at <code>ledgers</code> but if the constraints are applied transparently through Collection types, how come I can&#8217;t descend below the Collection to get a subsubquery object constrained to <code>Ledger</code>.class that would be the one I could execute?</p>

<p>I went through countless renditions of the above and had the same problem. One variation allowed me to do substring searching, (ie LIKE):</p>

<pre><code>String titleFrag = "Furn";
String nameFrag = "Cost";
...
Query query = container.query();

query.constrain(Account.class);
query.descend("name").constrain(titleFrag).contains();

Query subquery = query.descend("ledgers");

subquery.constrain(Ledger.class);
subquery.descend("title").constrain(nameFrag).contains();

ObjectSet results = subquery.execute();
</code></pre>

<p>Variations on this theme would either return that single <code>LinkedHashSet</code> or worse would return <em>all</em> the <code>Ledger</code>s in the datastore. Ick.</p>

<h2>Workaround</h2>

<p>What ended up fixing the problem was to add a navigation reference from Ledger to the parent Account. I already had that pattern in various other places (for instance in <code>Entries</code> which are the bridge between transactions and accounts/ledgers, have references to both their parent <code>Transaction</code> and their parent <code>Ledger</code>) so adding a parentAccount reference to <code>Ledger</code> was just a few lines of code.</p>

<p>[This of course adds a whole field and object-to-object relationship so in persistence terms this means that all the objects of type <code>Ledger</code> already in the data store would need to be updated. This is what makes me nervous about db4o. At the moment it&#8217;s all just mockup data that I&#8217;m recreating each run, but in production use? They provide some really neat hooks to deal with this sort of thing but it strikes me that this would be really easy to screw up]</p>

<p>Now to get the <code>Ledger</code>s I want I just do <code>Ledger</code>.class first and descend &#8220;up&#8221; the object graph:</p>

<pre><code>Query query = container.query();

query.constrain(Ledger.class);
query.descend("name").constrain(nameFrag).contains();

subquery.descend("parentAccount");

subquery.constrain(Account.class);
subquery.descend("title").constrain(titleFrag).contains();

Query subquery = query.descend("ledgers");

ObjectSet results = query.execute();
</code></pre>

<p>So the thing thats bugging me is adding &amp; maintaining this kind of navigation reference just to get around what I view as a weakness in the query mechanism provided by the persistence store.</p>

<p>Actually, the thing bugs me even more is the fact that to navigate through the graph you have to naming the private fields of the classes you want to go to in String form. So much for getting the compiler to type check for you. Of course, with something like Hibernate you have to name, in string form in an XML file, bloody everything by exact name that is in both your classes <em>and</em> in your database. But back to this problem, if I just assumed everything [that needs to be] was in memory, and used appropriate classes (ie, <code>TreeSet</code>s for large sets that need to be sorted, or <code>ArrayList</code>s for things that need to be iterated through) then I could probably avoid needing db4o&#8217;s query mechanism entirely.</p>

<p>Which would actually be <em>just fine</em>. It&#8217;s not like there are hundreds of thousands of these things &#8212; there are just hundreds, max. Sigh. It really is easy to over-engineer things. <code>:)</code></p>

<p>It&#8217;s been a good exercise of their API, however, and out-of-band querying is still pretty cool. I&#8217;ll certainly need it when it comes time to allow users to do searches to isolating specific Transactions they might have interest in.</p>

<h2>Strongly Typed arrays versus Collections</h2>

<p>I did see some indication in the db4o forums to the effect that a strongly typed array would be easier to use than Java Collections of them, ie <code>Hobbit[]</code> array versus (say) a <code>Set</code> of them. Certainly, this whole <code>descend()</code> thing would descend you into an array of the Type you want, not into a Collection where you get stuck.</p>

<p>I did some looking around on the net to see what people thought of using arrays versus Collections &#8212; not so much from a performance standpoint but rather from an API usability standpoint.</p>

<p>Broadly, the consensus out there seems to be that while strongly typed arrays are speedy things indeed [especially care of <code>System.arraycopy()</code>] and &#8220;nicer&#8221; to deal with because of the compile time Type safety, almost any use case imaginable would end up needing all the various methods that Java <code>&gt;=</code> 1.2&#8217;s Collections provide so you&#8217;ve got a lot of reimplementation to do.</p>

<p>One suggestion I saw in a Java forum somewhere was to store in arrays for steady state, but to switch to (say) a <code>HashSet</code> while you&#8217;re mucking with it and then ultimately export back to an array with <code>Collection.toArray()</code>. That seems interesting, but since the Collections are all internally implemented on top of <code>Map</code> instances and they in turn are implemented on top of <code>Object[]</code> you really aren&#8217;t buying much be writing all that machinery yourself.</p>

<p>Anyway, with respect to my adding a parent reference, now all I have to decide is whether this is an elegant solution and something I&#8217;ll need anyway, or a dirty hack which needs to be expunged before it sees the light of day. <code>:)</code></p>

<p><em>And, of course, I need to decide whether to keep using db4o or to switch to a ORM tool on top of an SQL database. The debate continues.</em></p>

<p>/me runs off to write some more unit tests.</p>

<p>AfC</p>
]]></description>
      <author>andrew@operationaldynamics.com (Andrew Cowie)</author>
      <category>/andrew/software/db4o</category>
      <pubDate>Wed, 21 Dec 2005 06:19:00 GMT</pubDate>
      <guid isPermaLink="false">querying-collections-in-db4o</guid>
    </item>


  </channel>
</rss>
