Question

The question is rather simple. I know that there is SQLite. There is Core Data also. But I need something in between. More object-oriented than SQLite API and simplier than Core Data.

Main points are:

  • I need access to stored entities only by id. No queries required.
  • I need to store items of a single type, it means that I can use only one table if I choose SQLite.
  • I want automatic object-relational conversion. Or object-storage if the storage is not relational.

I can use object archiving, but I have to implement things (NSArchiver).

But I want to write some kind of class and get persistence automatically. As it can be done with Hibernate/ActiveRecord/Core Data/etc.

Thanks.

Was it helpful?

Solution

Beyond BNRPersistence, which Alex points out, I don't think you're going to find anything that maintains object relationships, yet is simpler than Core Data on the Cocoa platforms. An object wrapper around SQLite like FMDB still requires you to manage relationships in your own code.

Maintaining relationships between objects is a non-trivial task, which is why you see so few of these frameworks out there. Core Data gets it right for many people, so there isn't that much motivation among developers to build an alternative to Apple's solution. BNRPersistence was created out of Aaron Hillegass' long-time frustration with certain aspects of Core Data, but many people (like me) are perfectly happy with the way Core Data does what it does.

You might also want to look at Core Resource, a newer framework that provides some wrappers around Core Data to make common tasks easier.

OTHER TIPS

Everything you've said you want here is completely compatible with Core Data. Apple's giving you a solution that meets your stated needs exactly, so why are you trying to avoid it?

You might consider a non-Objective-C approach to serializing objects, just as XML or JSON, where you don't have to write serialization code, if you don't want to, because the framework does it for you. For example, put your objects into a key-value attribute pairing with NSDictionary (via a wrapper class or whatever) that points to another record's id key, and then encode the mess with json-framework's JSONRepresentation call. You'd probably need to do your own relationship integrity tests, but voila, instant relational database.

Take a look at BNRPersistence.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top