Pages

Sunday, 5 February 2012

JDO Sample project with DataNucleus 3

/**updating ...*/

In this article, I will write a simple demo program to demonstrate the use of JDO to persist data to database.

This program will show a simple sport store, the products in store are sport clothes, kits, shoes, accessories, ...

So, the database schema here looks simple: we have two types of entity, one for category, and one for product. We also have an one-to-many relation from a product to a list of categories, it means that a product maybe belongs to more than one categories. Also notice that, of  course, in a category, we can have a number of products, but in this simple example, I will not use a many-to-many relation, so the categories don't know anything about product.

We have some prerequisites use in this example:
  1. MySQL 
  2. Data Nucleus 3.0
You can find these components from the pom.xml of this sample project.

Initialize project structure


Write POJOs to leverage JDO, ORM


Data persistent class


Put some UI to manage your store


Conclusion

No comments:

Post a Comment