Mixing ActiveRecord classes and Java Classes

Hi,

When there are java classes that are imported into a jruby Rails
project (i.e com.domain.system.User), which is referenced as User
after java_import, and we’d like to connect the class User to
ActiveRecord to do more operations on users table. What is the
standard way of doing this to avoid naming conflicts?

Is there a way to do this using the same class name? so that we can do
both of:
User.java_method
User.active_record_method

Maybe something like java_include from the ActiveRecord class, or
maybe make the ruby class inherits from the java class and then add
the ActiveRecord functionality some other way.

Cheers.

On Mar 21, 2012, at 12:36 PM, Samer A. wrote:

User.active_record_method

Maybe something like java_include from the ActiveRecord class, or
maybe make the ruby class inherits from the java class and then add
the ActiveRecord functionality some other way.

Is persistence for your java User class already managed by another ORM
like Hibernate? It would smell pretty bad to me having persistence for a
single entity(one table) implemented across multiple ORMs. We have a
core set of domain model classes implemented via Java/Hibernate. We keep
all persistence for those models through Hibernate, but freely add new
behavior to them by extending the extending/re-opening them in ruby. You
can still reap many of the ActiveRecord goodness like validation macros
by mixing in ActiveModel stuff.

ex.

include_class ‘org.aps.eop.model.manuscript.Journal’

class Journal
class << self

end

-lenny