Skip to content
Print

SaveableEntity Bids a Fond Farewell

15
Aug
2007

Well, to make a small, side entry out of something which probably should be in bold print on the ActiveObjects website…  It’s worth announcing that I’ve merged SaveableEntity into the Entity super-interface.  The only reason to keep these two separate was so that some entities could be configured to receive calls to setters and immediately execute UPDATE statements.  This is a really inefficient way to code your database model and I think the only real use of it was in my sample code.  :-)   Since it really was an API misstep, I’ve decided to do away with it.  The save() method is now obligatory for any data modification.  Thus, any legacy code you may have which extended Entity may not function in the way you would expect (e.g. the DogfoodBlog example no longer persists data properly).  If you have any code which extended SaveableEntity, just change this to extend the Entity interface and everything should work as before.  Just thought I’d make a general announcement.

Comments

  1. After some tests I decided to use AO in the one real-life project. Here I still think how to resolve lazyness problem. I need to load a list of companies and their assotiated contacts. Is there any way how to do it in one query?(I list 30 companies per view what means one db query to get companies and 30 queries to get their contacts) Standard approach for getting contacts requires database hit for every company. I thought to use ‘join’ statement in Query but not sure how to use it or wheteher it is even proper solution.

    Thanks for any advice.
    David

    David Marko Tuesday, August 21, 2007 at 12:21 am
  2. Hmm, well if you need to get both the companies *and* the contacts, that does pose a bit of a problem. If you wanted to get just the contacts for all the companies, you could use the Query#join method, but that will only return you the contacts. Like this:

    Contact[] contacts = manager.find(Contact.class, “contacts.id”, Query.select().join(Company.class, “contacts.companyID = companies.id”));

    However, this won’t eagerly load any values in Contact or in Company. The only way I can think of which ActiveObjects could solve this problem for you is if I found a way to eagerly load relation values. It is possible I suppose, now that I think about it. The problem is that I would need to cache the related values somewhere, and AO currently has no concept of a relations cache. Actually, caching relations without leading to stale values is one of the problems I’ve been thinking pretty hard about recently.

    If I were you, I’d either do this in a separate query done directly in JDBC (you can get a Connection instance from manager.getProvider().getConnection()), or I’d accept the cost of the extra queries and go with it (not a good option). Alternatively, you could wait for me to figure out how to cache relations and use that functionality once it arrives (which would be the easiest solution to the problem). :-)

    daniel Tuesday, August 21, 2007 at 10:08 am
  3. ActiveObjects version 0.5 is released. May I know what is the changes/additions? Is there a roadmap and timeline for future releases that we can look forward to?

    Regards,
    James Yong

    james yong Wednesday, September 12, 2007 at 9:10 am
  4. Yeah, I probably should start keeping a changelog or something…

    Right now, the best way to figure out what’s different is to look in the SVN commit messages since the v0.4 tag. The short list as I can remember it:

    * More efficient relations fetching and advanced relations caching
    * Dozens of bug fixes (partially due to the new test suite)
    * Customizable field name conversion conventions (allowing more flexibility with the schema)
    * Field preloading (including respect for this in relations fetching)
    * …random new features I can’t remember

    We’re not really looking at too many new features coming into 1.0. In fact, the ones we’ll add will probably be extremely minor. Relations preloading may or may not actually make it into 1.0; there’s a lot of changes required for it. Mainly at the moment I’m focusing on Javadocing and more and better tests.

    daniel Wednesday, September 12, 2007 at 10:26 am

Post a Comment

Comments are automatically formatted. Markup are either stripped or will cause large blocks of text to be eaten, depending on the phase of the moon. Code snippets should be wrapped in <pre>...</pre> tags. Indentation within pre tags will be preserved, and most instances of "<" and ">" will work without a problem.

Please note that first-time commenters are moderated, so don't panic if your comment doesn't appear immediately.

*
*