Hi,

I've been hacking around Jibernate and I'd like to start an open discussion
about the project and its future.

Right now the project is not useful at all, it's just a wrapper to create
basic models with attributes, it has some bugs, it's not gemified... But,
from the point of view of an old hibernate user it has a promising future.
Hibernate is more mature than other orm frameworks like ActiveRecord or
DataMapper and since rails 3 is decoupling its layers it could be a good
choice for old java developers moving to rails that want to use this
framework.

So, for me, the final goal for the project should be to be fully compatible
with rails 3. Meanwhile there are a lot of work to do.

Yesterday evening I forked Nick Sieger's repository,
http://github.com/calavera/jibernate, and I started to clean directory
structure a little bit, doing some little changes and adding some tests. I
also moved the mapping template generation to Erubis, it's faster than ERB,
it can cache templates and avoids object bindings.

So, I think this is a good point to start working but there are a few points
to discuss-decide:

    - should it have its own place? right now I forked Nick that forked
Charlie, I think it should be move to a more appropriate place, like
github.com/jruby/jibernate or kenai.com/projects/jibernate
    - should we use a gem build tool to package it? right now there isn't a
way to create a gem. Projects like Jeweler alow to package and distribute
gems easily but it can also be done by hand. I vote to use Jeweler.

There are also other questions about the design of the api, how to implement
relationships?, should we support the full hibernate api? should we use the
rails convention for database names or another one?...

As my first task I'd like to write a basic implementation of relationships,
one-to-many and many-to-one. This is how I think the api should be:

class Parent
  include Hibernate::Model
  hibernate_has_many :children => Child
  hibernate!
end

It should generate
<set name="children">
  <key column="CHILDREN_ID"/>
  <one-to-many class="ruby.Child"/>
</set>

class Child
  include Hibernate::Model
  hibernate_belongs_to :parent => Parent
  hibernate!
end

it should generate
<many-to-one name="parent" class="ruby.Parent" column="PARENT_ID"/>

The main problem with this api is how hibernate works. When you add a
mapping file to the configuration it tries to load all classes related with
it, so when it adds the Parent mapping it tries to load the Child class and
it checks accessors are right, but it breaks because the other class is not
defined, you can try to load the child class first, but it also needs the
Parent class... blah blah, resulting an infinite loop.

SO, this is the point where the project is right now, advice, comments,
suggestions... are welcome.

Cheers

Reply via email to