Showing posts with label db4o. Show all posts
Showing posts with label db4o. Show all posts

Monday, November 28, 2011

Entity abstraction for Scalapi

I created an abstraction for storing and accessing persistent entities using the Scalapi library.

I find it useful when experimenting with various data providers and comparing benchmarks results.

Below you can see example of its usage to feel the flavor of this API.
// Define entity class
case class SampleEntity(id: String) extends Entity[String] {
  entityId = Some(id)
}

// create DB4O entity store
val objectContainer = Db4oEmbedded.openFile("/tmp/db")
val entityStore = new Db4oEntityStore(objectContainer)

// Store entity
entityStore.store(new SampleEntity("id"))

// Find entity
val query: Predicate[SampleEntity] = (entity: SampleEntity) => entity.getEntityId() == Some("id")
val results = store.query[SampleEntity](query)

Thursday, October 7, 2010

Released db4o component for Camel

I contributed db4o component for Apache Camel. It is hosted under Camel-Extra Project, like all *GPL-related Camel components.

New component allows you to use a db4o datastore as a logical queue. Consumers take messages from the db4o store and then delete them to logically remove them from the queue. On the other hand sending POJO object to the db4o endpoint adds and saves object into the database. Detailed usage is described in the reference documentation.

Enjoy.