The latest journey in my quest to see just how many new technologies and frameworks I can learn in one week involves Morphia. Morphia is a "Java Object Document Mapper for MongoDB". In other words, it let's us map our POJOs and POGOs to MongoDB Documents and persist them in MongoDB.
Right, so, on to the codes. To get started with Morphia declare a dependency as such:
compile group: 'org.mongodb.morphia', name: 'morphia', version: '1.3.1'Obviously you'll need to make sure you've got access to a running instance of MongoDB before you try to connect/persist to it. Next, create a domain class - we'll call this one
We've annotated this domain class with
@Entity and the ID with
@Id as required by the framework. To make things a bit more realistic, I've wrapped some common functionality for dealing with a
Person in a
PersonService. The service will handle getting a reference to the framework and the datastore (I'd probably include that in an abstract service in a real application) and has a
findById() method. Standard stuff:
Next we'll create a simple route in Spark Java to interact with our
PersonService, create and persist a new
Person if necessary and return a list of Persons to our view.
And finally, the view code if you're dying to see that:
Which results in the following:
And that's simple object based persistence in MongoDB via a Spark Java application.
I have blogged quite a bit about serverless Oracle Functions here on this blog, including several various examples about function invocation. But, I've...
A few weeks ago, I blogged about a utility that I created that helps you debug your serverless functions in the Oracle Cloud. The code behind that project...
Working with serverless functions represents a new way of thinking for many developers. Dealing with stateless functions, for example, can be a challenge...