Forum: JRuby JRoR: Co-existing with Java/Hibernate back end

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2009-02-25 21:32
(Received via mailing list)
* I submitted this through the Web forum interface and never saw it come
through on the list, so I wasn't sure if it made it through.  So I'm
reposting it here.  Could be that it made it through and it's a crappy
question and I'm ok with that ;).  So if it's a repost, sorry.  If it's
not, now you know *

All,

I'm looking at a project where I'm being asked to focus mostly on the
front-end development.  I don't have all of the details yet, but the
implication is that the model layer is going to be handled completely in
Java, presumably using Hibernate.

This gets me thinking about how to manage the model side of things with
Rails.  Do I effectively create a set of non-DB backed models and then
shuttle data back and forth to Hibernate?  This feels really not good to
me.

I'm looking for people who have experience working on a JRoR project
where Hibernate was involved.  Did you run into issues where the Rails
model layer and Hibernate where competing for management of the same
model objects?  Or did you just give each framework non-overlapping
groups of models to manage?

Any feedback is appreciated.

The right answer is not "just use Rails for everything," btw ;).

Thanks,
Wes Gamble

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
2e793cdf2d72aecd526a081ae2f1865b?d=identicon&s=25 Johnny P (Guest)
on 2009-02-26 17:48
(Received via mailing list)
Wes, without having specifics on your project it is hard to say;
However, I can say that I have had great success with Spring,
Hibernate, RMI, and JRuby.  No issues other than coercing objects
between Ruby and Java, which boiled down to some form of to_java, or
getting it right.  There are probably other things to know, but I
suspect there are no show stoppers.

On Wed, Feb 25, 2009 at 12:31 PM, Wes Gamble <weyus@att.net> wrote:
> implication is that the model layer is going to be handled completely in
> model objects?  Or did you just give each framework non-overlapping
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2009-02-26 18:03
(Received via mailing list)
Johnny,

So, in your case, you weren't using Rails I assume?

If so, where did you get your "bang for the buck" from the Ruby side of
things?  Just curious.

Wes

Johnny P wrote:
>> through on the list, so I wasn't sure if it made it through.  So I'm
>>
>>
>>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
7c02e94043800ebd486cc25963a47b81?d=identicon&s=25 Jan Berkel (Guest)
on 2009-02-26 18:06
(Received via mailing list)
a project i worked on had a similar architecture: some backend
processing in java+hibernate and a web frontend in rails. we ended up
changing the schema on the hibernate side to make it activerecord
friendly (plural table names, underscores  etc) and then accessed data
using AR on the rails side.

then we decided to get rid of hibernate completely (it was too much
effort maintaining a parallel model hierarchy) and moved the backend
processing from Java to JRuby+AR, which worked fine (there's very
little advantage of using hibernate in terms of functionality now,
besides better "legacy db" support).

you might be able to create JRuby model proxies, which do some clever
things with hibernate metadata (autogenerate methods a la AR). i think
some people tried that, but don't remember the names of the projects.

  jan

On 25 Feb 2009, at 20:31, Wes Gamble wrote:

> implication is that the model layer is going to be handled
> I'm looking for people who have experience working on a JRoR project
> Wes Gamble
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2009-02-26 19:12
(Received via mailing list)
Jan,

That's kind of what I foresee could happen.  I definitely wouldn't
bother changing the schema just to meet Rails conventions - that's not
really necessary.

One upside of a "parallel model" approach is that you can treat the
Rails models as non-table backed and purely UI-focused, treat the Java
models as the "real" models and then marshal data across the "R-J
junction" however you want (e.g. aggregate N Java models into one Rails
model or whatever).

Thanks for the thoughts.

WG

Jan Berkel wrote:
> little advantage of using hibernate in terms of functionality now,
>> * I submitted this through the Web forum interface and never saw it
>> Java, presumably using Hibernate.
>> groups of models to manage?
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
2e793cdf2d72aecd526a081ae2f1865b?d=identicon&s=25 Johnny P (Guest)
on 2009-02-26 22:41
(Received via mailing list)
No not rails, but Swing.  The bang for the buck was I could develop
tools with gui frontends much faster and usually in one jruby file.

On Thu, Feb 26, 2009 at 9:02 AM, Wes Gamble <weyus@att.net> wrote:
>>
>>> * I submitted this through the Web forum interface and never saw it come
>>> implication is that the model layer is going to be handled completely in
>>> model objects?  Or did you just give each framework non-overlapping
>>> To unsubscribe from this list, please visit:
>>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
54568ee7ba0c78a836e84c8756a3d681?d=identicon&s=25 Lenny Marks (Guest)
on 2009-03-01 00:14
(Received via mailing list)
We've been developing Jruby/Rails apps with Java/Spring/Hibernate for
long time now and very successfully. Below is a post from long ago,
but it's still pretty accurate.

http://www.nabble.com/Re%3A-views-controller-in-Ru...

I'd also add that another big gain has been the ability to re-open our
java classes and extend them for our Ruby applications as well as
being able to do BDD with rspec for java and ruby classes alike.

In java we had the full layered architecture(domain model/dao/service)
with dependency injection via Spring. From the outside in perspective,
it seems a bit clunky sometimes dealing with 3 different layers to
accomplish any given thing, but it was pretty much necessary so that
mocks/stubs could be injected for testing. A static finder method in
java left no easy way to hook into the return value without hitting
the database. In Jruby there are no testability tradeoffs to making
the API look the way I'd prefer it to be.

ex.

class Manuscript
    def self.find_by_accode(accode)
       SpringAppContext.get_bean(:manuscriptDAO).findByAccode(accode)
    end
    ..
    def save

SpringAppContext.get_bean(:manuscriptService).saveManuscript(self)
     end

    ...

Using rspec, Manuscript.should_receive(:find_by_accode).and_return(m)
is not a problem.

I can't say I'd choose to do a new Rails app from scratch using
Hibernate and Spring, but accessing our pre-existing API from JRuby is
even easier than from plain Java.

-lenny

On Feb 25, 2009, at 3:31 PM, Wes Gamble wrote:

> implication is that the model layer is going to be handled
> I'm looking for people who have experience working on a JRoR project
> Wes Gamble
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.