Upon investigation, I found that JRuby throws a wrapper around Java objects in some circumstances. The wrapped object cannot be saved by DB4O, or so I have concluded. My follow up strategy was going to be to define a class in java and try to instantiate it in JRuby to see if it would save to a file. I may be on the right track.
A search of the Db4O forums has led me to the following excellent information, provided by Jason Thomas. I will attempt to make use of this information, and I will write about the result. While you wait, follow the link I have posted above – it is interesting.
Note: (Added November 20, 2008) I have since returned to my investigations of how to use DB4O using scripting languages running on the JVM. See my work with Jython and the Django framework using DB4O. My BS theory of JRuby throwing a wrapper around Java objects is probably out to lunch. I may come back to this, but feel free to see what I am doing with Jython to see if it applies to JRuby.
I have managed to get JRuby up and running, and I am using Netbeans to edit my code. I am pleased. I can create Ruby on Rails projects, and I can start and stop servers from the IDE. All good.
Today, I started to play with DB4O – I have hit a small snag. The objects I want to save will NOT save – I am getting an ObjectNotStorableException. I am sure that all I need to do is read some more – my objects are Ruby objects not Java objects. (I thought I was inheriting from proper Java classes, but I am sure I can work through this.)
I will also try this with Jython – and, I found a version of PHP5 that runs on the JVM. I will keep you posted. As usual, I do not have a lot of time.
Today, my six year old step daughter and I rode our bikes to the bakery to get breakfast for the family. This was her first purposeful bike ride, and it was the first time she had every ridden on the road. She was very proud of herself – and I was proud of her, too.
In the afternoon, I proposed that we are drive out to Carleton Place for no reason. We looked around, bought some books, and had supper at a lovely little Irish pub. Technology had to wait, and that is as it should be.
However, I would like to find time to generate some excitement about DB4O for scripting languages that run on the JVM.
DB4O is not a database, per se, or a database substitute. It is an object persistence tool – or, an object database. An object is more than data. As such, it can help you save, delete, find and update objects that have been created using either Java or a .NET based language. On the .NET side, therefore, it is possible to use DB4O with IronPython or IronRuby – pretty well any language that runs on the CLR. I have not done this myself, and I have to point out that code examples may be in short supply, but it can be done.
Some people might assume that Db4O is more versatile when used under Mone or the .NET framework, but that is not so. The Java community is busy finding ways to make dynamic languages run on under the JVM. Notably, there is Jython, an implementation of Python. There is also JRuby, an implementation of Ruby. I have even read that Ruby on Rails will run under JRuby, which would give RoR developers access to all sort of Java class libraries.
Can you imagine RoR and having access to objects that are being managed by DB4O? In the DB4O forums, the odd person will ask if Db4O will work with PHP, or some other language. The answer should not always be no. I do not have the time right now, but if someone is playing around with these ideas, I would like to here about.
Somebody will get Django to run using IronPython – perhaps even Turbogears. Combining these frameworks with the CLR or the JVM could make it possible to use many other computer languages with DB4O. The door is not closed, but someone needs to make it happen. This is an interesting area. I am interested in using JRuby to run on the JVM, opening the possibility of using DB4O with Ruby on Rails – then, it would be interesting to build a version of Activerecord using DB4O. (Justing thinking out loud.)
Hint: If you use Jython, the key is to inherit from a Java class. If you create an object based on a Python class, it will not persist using DB4O. Good luck.