13

I'm looking at ORMs for Java and Active Objects caught my eye. Apparently, it was inspired by Rails' ActiveRecord. Based on what I've read, this approach seems to solve a lot of problems with existing Java ORMs by embracing convention over configuration.

What's been your experience with it?

g.annunziata
  • 3,118
  • 1
  • 24
  • 25
Rich Apodaca
  • 28,316
  • 16
  • 103
  • 129
  • I was also looking for a lightweight ORM and also found ActiveObjects. The last release seems to be from april 2008 and I guess the project is dead. From the authors blog I can see that he's more into Scala nowadays. Besides that, there also seems to be a lack of sufficient tutorial style documentation for this project. It looked really promising but I think I have to find something else than ActiveObjects. – Luke Jan 16 '10 at 06:00

4 Answers4

9

Be careful that you don't wander into "silver bullet syndrome"... I just hear devs saying "convention over configuration" and think it's a great thing...

Daniel Spiewak is a solid programmer, I've learned a lot from his blog, but this is a fairly simple API. That means, don't expect a ton of experience with production usage, working in a high-load environment, etc. But sometimes, all you need is simple, and well, there are other projects, like Databinder that integrate with Active Objects. (Wicket + Databinder is a pretty nice, lightweight web framework for Java.)

But, for example, I'd stay away from a persistence framework like this if I was doing a lot of batch processing. Mostly, because I want:

  1. Immutable objects by default, which naturally flows into multi-threaded processing, because you force people to a "delete/create new" instead of "update" sort of paradigm, which saves a lot of disk usage in many DBs.
  2. DB access that considers simplifying IO by using specialized commands like COPY

I've solved a lot of DB performance problems by just writing straight SQL code, replacing the use of an ORM that wasn't suited for the task.

Tristan Juricek
  • 1,804
  • 18
  • 20
  • you might want to look at [JIRM](https://github.com/agentgt/jirm) which is allows you to CRUD immutable objects... yes that is a shameless plug :) – Adam Gent Nov 07 '12 at 14:24
5

DISCLAIMER: I am the primary developer working on a project called ActiveJDBC which shares some design goals with ActiveRecord and is actively in development:

http://javalite.io

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
4

Active Objects is under active development at the moment, thanks in part to being picked up by Atlassian as a likely plugin data persistence engine to use with its suite of enterprise software.

The Active Objects project is now housed at http://java.net/projects/activeobjects/pages/Home

The Atlassian plugin that uses Active Objects is tracked at https://studio.atlassian.com/browse/AO

In particular, note that Atlassian have just started to build the documentation for the Active Objects Library, at https://developer.atlassian.com/display/AO/Active+Objects

The code hosting is being migrated to BitBucket, and the SCM from svn to mercurial. Watch bitbucket.org/activeobjects/ for progress on that front.

Cogito
  • 357
  • 2
  • 5
1

Here some citation from why-another-orm.txt included in ActiveObjects-core: ActiveObjects is designed from the ground up to be as easy to use as possible, with a bare minimum of configuration....There is an increasing trend in the industry towards "convention over configuration."... In fact, ActiveObjects strives so hard to be a simple and easy-to-use persistence framework that some functionality (such as distributed transactions) has been simply omitted. The reasoning behind this is that 99% of use-cases do not call for such extreme measures. If your project does require such complex behavior within your ORM, you should be using Hibernate. It's as simple as that. ActiveObjects is not intended to supplant Hibernate. Rather, its goal is to be an easier and lighter alternative for the many common scenarios which do not call for all of Hibernate's awesome power. In short, ActiveObjects attempts to make database development simple and fun again.

Consider companies like Atlassian using ActiveObjects in JIRA.

Here's an example of using ActiveObjects:

Repositories:

https://maven2-repository.dev.java.net/

Use the following dependencies:

  <dependency>
      <groupId>net.java.dev.activeobjects</groupId>
      <artifactId>activeobjects</artifactId>
      <version>0.8.2</version>
  </dependency>

Create the following files:

Entity.java

    import net.java.ao.RawEntity;
    import net.java.ao.schema.AutoIncrement;
    import net.java.ao.schema.NotNull;
    import net.java.ao.schema.PrimaryKey;

    public interface Entity extends RawEntity<Integer>{

        @AutoIncrement
        @NotNull
        @PrimaryKey("id")
        Integer getExportId();
    }      

TestAO.java

    import net.java.ao.Preload;
    import java.sql.Timestamp;

    @Preload
    public interface TestAO extends Entity {

        String getFirstName();
        void setFirstName(String firstName);

        String getLastName();
        void setLastName(String lastName);

        Timestamp getUpdateTimestamp();
        void setUpdateTimestamp(Timestamp updateTimestamp);
    }

Test.java

    EntityManager entityManager = EntityManager("jdbc:mysql://localhost:3306/test","test","test");
    ao.migrate(TestAO.class);
    TestAO testAO = ao.create(TestAO.class);

    testAO.setFirstName("firstName");
    testAO.setLastName("lastName");
    testAO.save();
Andrew Swan
  • 13,427
  • 22
  • 69
  • 98
aberes
  • 297
  • 1
  • 6