ZK With MongoDB Part 1 - Using MongoDB Java Driver"
m (Created page with "{{Template:Smalltalk_Author| |author= Ashish Dasnurkar |date=Jan 18, 2012 |version=ZK 5 }} {{Template:UnderConstruction}} =Introduction= ZK is primarily an UI framework and i...") |
m |
||
Line 10: | Line 10: | ||
ZK is primarily an UI framework and it doesn't make any assumptions about application's persistence layer or database. Application developers are free to use any database (relational or non-relational) and any data access layer solutions that work with those databases. Typically, for relational databases developers either use plain [http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/Integration/JDBC JDBC] or some sophisticated object-relational mapping library like [http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/Integration/Hibernate Hibernate]. In this small talk series I will show how developers can develop [http://en.wikipedia.org/wiki/NoSQL non-relational database] driven ZK application. | ZK is primarily an UI framework and it doesn't make any assumptions about application's persistence layer or database. Application developers are free to use any database (relational or non-relational) and any data access layer solutions that work with those databases. Typically, for relational databases developers either use plain [http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/Integration/JDBC JDBC] or some sophisticated object-relational mapping library like [http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/Integration/Hibernate Hibernate]. In this small talk series I will show how developers can develop [http://en.wikipedia.org/wiki/NoSQL non-relational database] driven ZK application. | ||
+ | |||
+ | I will describe a simple TODO list application that uses [http://www.mongodb.org/ mongoDB] which is a popular non-relational database. In this series I will show three approaches to work with mongoDB. In Part 1 I will use mongoDB [http://www.mongodb.org/display/DOCS/Java+Language+Center#JavaLanguageCenter-JavaDriver Java driver] APIs for TODO tasks CRUD operations which is similar to using JDBC driver for relational databases. In Part 2, I will use [http://code.google.com/p/morphia morphia] , a lightweight type-safe library for mapping Java objects to/from mongoDB, which is similar to using Hibernate for relational databases. Finally for developers who are familiar with Spring framework, in Part 3 I will show how to leverage Spring Data mongoDB support to work with mongoDB database. | ||
+ | |||
+ | =mongoDB Overview= | ||
+ | |||
+ | mongoDB is a document oriented database that manages collections of [http://bsonspec.org/ BSON] documents. Each BSON document is a set of fields. Each field is a key-value pair where key is a string and value can be other basic types, a BSON document or array of values. Below is a sample of tasks collection | ||
+ | |||
+ | <source lang="java"> | ||
+ | |||
+ | { "_id" : ObjectId("4e97d8b7dfa2925b0844a3c9"), "id" : "c011a1df-22ab-4607-a358-ea2f2873b51e", "name" : "Write article", "priority" : 1, "date" : ISODate("2011-10-06T16:00:00Z") } | ||
+ | { "_id" : ObjectId("4e97d8e5dfa2925b0844a3ca"), "id" : "ce4a059f-1825-4410-bf95-4c30e11aca14", "name" : "Conference call", "priority" : 2, "date" : ISODate("2011-10-13T16:00:00Z") } | ||
+ | { "_id" : ObjectId("4e97d8f0dfa2925b0844a3cb"), "id" : "0b0db7ac-b5db-40a6-9c8e-2c86581a3e89", "name" : "Release 5", "priority" : 1, "date" : ISODate("2011-10-27T16:00:00Z")} | ||
+ | |||
+ | </source> |
Revision as of 06:53, 12 January 2012
Ashish Dasnurkar
Jan 18, 2012
ZK 5
Introduction
ZK is primarily an UI framework and it doesn't make any assumptions about application's persistence layer or database. Application developers are free to use any database (relational or non-relational) and any data access layer solutions that work with those databases. Typically, for relational databases developers either use plain JDBC or some sophisticated object-relational mapping library like Hibernate. In this small talk series I will show how developers can develop non-relational database driven ZK application.
I will describe a simple TODO list application that uses mongoDB which is a popular non-relational database. In this series I will show three approaches to work with mongoDB. In Part 1 I will use mongoDB Java driver APIs for TODO tasks CRUD operations which is similar to using JDBC driver for relational databases. In Part 2, I will use morphia , a lightweight type-safe library for mapping Java objects to/from mongoDB, which is similar to using Hibernate for relational databases. Finally for developers who are familiar with Spring framework, in Part 3 I will show how to leverage Spring Data mongoDB support to work with mongoDB database.
mongoDB Overview
mongoDB is a document oriented database that manages collections of BSON documents. Each BSON document is a set of fields. Each field is a key-value pair where key is a string and value can be other basic types, a BSON document or array of values. Below is a sample of tasks collection
{ "_id" : ObjectId("4e97d8b7dfa2925b0844a3c9"), "id" : "c011a1df-22ab-4607-a358-ea2f2873b51e", "name" : "Write article", "priority" : 1, "date" : ISODate("2011-10-06T16:00:00Z") }
{ "_id" : ObjectId("4e97d8e5dfa2925b0844a3ca"), "id" : "ce4a059f-1825-4410-bf95-4c30e11aca14", "name" : "Conference call", "priority" : 2, "date" : ISODate("2011-10-13T16:00:00Z") }
{ "_id" : ObjectId("4e97d8f0dfa2925b0844a3cb"), "id" : "0b0db7ac-b5db-40a6-9c8e-2c86581a3e89", "name" : "Release 5", "priority" : 1, "date" : ISODate("2011-10-27T16:00:00Z")}