Summer of Code/2011/MoveToHibernate

From OpenNMS
Jump to navigation Jump to search

Personal details
Name: Yang (Bruce) Li
University: Michigan State University, MI, United States
Course/Major: Computer Science and Engineering
Email address:
Physical Address: 3115 College of Engineering, MSU, East Lansing, MI 48824
Web page:
IM Contacts: yh-dih (Skype ID)
IRC Nick (If you are on #opennms): liyang5

- How much time do you plan to spend on your GSoC project?
From May to August, 40-60 hrs/wk.

- What is your intended start and end dates
May 1st - Aug 22nd, 2011

- What other factors may affect your availability(vacations, exams, etc)
No other activities during that slot.

- Will your start date be delayed by exams or for other reasons?
No, I will be free from this May.

Background Information
-What is your education background?
*Bachelor of Engineering Degree in Computer Science, expected Master of Science Degree in Computer Science and Engineering this year.
My current overall GPA is 3.9/4.0 with software/networking oriented courses, such as Software Engineering, Design Pattern, Wireless Sensor Networks, Operating System, Graph Theory, Network Security and so on

-What is your software development background?
*Excellent algorithm knowledge, programming and debugging skills in C++, Java/J2EE and Flex Web Service framework
*Software Designer Certificate with 2 years' enterprise-level J2EE/Flex project development experience

-Why are you interested in OpenNMS?
*As an open-source enterprise-level network management system, OpenNMS provides great network monitoring capabilities with scalability and flexibility. In technical aspect, OpenNMS fully facilitates the open-source web application framework such as GWT, Hibernate and Spring. Through the demos of OpenNMS, I found these products have great user experience, and it really caught my eyes for their rich functionalities and speed. For me, my educational background focused on web application development, and my industry experience is highly related to the application development based on web services. I believe I am a good fit in this project development. Most importantly I love challenges, and I believe joining OpenNMS development can offer me such an opportunity to contribute what I have learned before. That’s why I am interested in OpenNMS development.

-Why are you interested in free and open source software?
*Compared with commercial software products, free open-source software has better flexibility, since under appropriate management, open-source project can be very agile and deployed cohesively to user's requirement. It also enjoys better security in some extent since bugs can be fixed quickly.

-What is your experience with free and open source software?
*I have internship experience in 2009, and I participated in a enterprise-level J2EE project development using Spring/Webwork2/Hibernate open-source framework with Oracle9i database backend. I participated in the full lifecycle development including Hibernate ORM, logical interaction implementation in Webwork and so on.

-Tell us about your previous work experience, even if it was outside of the IT world.
*Currently I am research assistant of MSU, the Main projects I am working on are flash-based RIA called Online Application Management System and Graduate Information Management System developed in Flex/ColdFusion/MySQL, which help the professors and committee members efficiently manage candidate profiles.
*Before my graduate study I have interned experience in Chinese largest telecommunication corporation, and I participated in a J2EE project development named Enterprise Knowledge Management System, which fully utilized the Spring/Webwork2/Hibernate framework with Oracle9i database backend. I participated in the development of ORM in Hibernate and logical interaction in Webwork (Structs 2.0)

-Give us one fun fact about yourself.
Rating scale:

* Java 6
* Distributed Version Control System 4
* Eclipse 6
* GWT 2
* Hibernate 6
* REST 0
* Apache Jersey 3
* Spring 5
* OpenNMS 1
* JMX 0
* SNMP 0
* PostgreSQL 4
* javascript 5
* Maven 2
* Linux 4
* Mac OS 4
* Windows 8
* junit 3
* IPv6 3
* JNA 0
* Docbook 0
* TCP/IP Network stack 3

If you are interested in the hibernate project, please answer the following -
-What is Hibernate to you?
*Hibernate is an open-source Object-relational Mapping framework for data persistence layer. In other words, it builds a mapping relationship between the Java persistent object and data entity in database. Hibernate enables the programmer control the data in the same way as the object in object-oriented programming. To use Hibernate, we need to build configuration file( or hibernate.cfg.xml) and mapping file(**.hbm.xml). Usually this type of configuration can be automatically generated by Eclipse IDE with proper plugins.

-Can you explain what an ORM does for you?
*ORM builds a relational mapping between the persistent object and data entity in database. In my project, ORM generates xml configuration file with the definition of class-to-table segment including segment name, type and so on. Based on this mapping, we can build sessionFactory and provide database operation functions such as get(), load(), save(), update() and delete().

-How is Hibernate related to spring?
*Spring is a light-weighted framework, it provides services layer management. It provides interface for the interactive actions, and encapsulate the DAO persistent layer built by Hibernate. It gives a unique managing method for javabean.
*The sequence of operating flow would be: jsp
àActionàServiceàDAOàHibernate. When the user-input data received from ActionFormBean, Action extracts the data from bean and encapsulate it into POJO, then call the Bean classes in service layer, forwards it to DAO interface after service processing to complete the data persistence.

-Have you setup complex relationships and cascading with hibernate?
*Yes, when we have multi-layer objects, we can define different types of paraments of cascade such as 'all', 'delete', 'save-update' to notice which operation should be cascaded from the parent objects to the associated objects. For example, if we set cascade = 'save-update', when the parent record is changed, its child records should also be updated.

-How does transactions work?
*Transaction is a series of database operations which follows the Atomic, Consistant, Isolated and Durable (ACID) principle. In Hibernate, the transaction is based on JDBC transaction.
The code to define transaction in Hibernate is like:
session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
And the underlying JDBC implementation is:
Connection dbconn = getConnection();

-Can you describe how Hibernate inserts data using transactions and roll-backs?
The transaction was explained as above. For roll-backs, it is implemented by exception catch. See the following example,
public void insert(Person p) throw BaseException{
Transaction tran=session.beginTransaction();;
throw new BaseException();

-Can you describe when a Left Join should be used?
*The Left Join querys and returns all records from the left table. For example, if we want to query all students' score and those absent from exam, we should query with the student as left table.

-Do you have an example of where you needed to optimize HQL?
*We can create a view for the database, then add entity class and a DAO file. Then use HQL to operate the data based on View, which I think is a kind of optimization.

Proposal Requirements

About Me

My name is Yang (Bruce) Li, a master student majoring in Computer Science and Engineering at Michigan State University. As a graduate student in computer science, my focused researching area includes web application programming and wireless programming. I am proficient in Flex/ActionScript/ColdFusion and Spring/Structs/Hibernate framework programming with proven industrial experience. I am also familiar with Maven, MVC and mainstream back-end database technique such as MySQL, PostgreSQL and Oracle.

As a research assistant and student project developer of MSU since 2009, I designed and implemented several enterprise-level management systems including Online Application Management System (OAMS), Graduate Information Management System (GIMS) and so on, and demonstration of projects are available at The above systems are currently in active use by the two departments of MSU. Even earlier than that, I interned in Chinese largest telecommunication company as a software developer in J2EE projects Enterprise Knowledge Management System(EKMS) for four months.

I still remember the experience when I first learned Spring/Structs/Hibernate J2EE framework to develop EKMS project for China Telecom, by using ORM data persistent framework Hibernate, it significantly alleviated our workload of writing complicated SQL language for each interactive database atom operation, and maintained ACID features to guarantee the security and integrity of enterprise-level application. Thus, knowing that OpenNMS is going to finish up the process of data access code conversion under Hibernate/Spring, I am eager to participate and improve this open-source project of GSoC 2011.

Hibernate is an open-source Object-relational Mapping framework for data persistence layer, it builds a mapping relationship between the Java persistent object and data entity in database. Hibernate allows developer to operate on database tables easily and avoid expensive change on code for underlying database modification. On the other hand, Spring is a light-weighted framework, which provides flexible services layer management. It has interface for the interactive actions, and encapsulate the DAO persistent layer built by Hibernate. It gives a unique managing method for javabean.

Inspired by these aforementioned features of Hibernate and Spring framework, it's nice to have OpenNMS platform migrate to DAO design pattern. First, the DAO can abstract and encapsulate data access which enables the flexibility that there's no need to re-write the application code even when database have been changed or moved. Second, the IoC mechanism in Spring provides IoC container for object management, which decouples the interface and its implementation by put them into XML file. Thus the object can be passed in the implement interface without extra looking up process.

Currently I've already built up the OpenNMS developing environment with all necessary components. I went throught all the codes about the DAO/DTO implementation. My effort of OpenNMS DAO migration project is planned to be seven-folded:

1. Find out all the database access code. Design and implement DAO interfaces of tables;

2. Provide Spring application context for DAO object management;

3. Integrate the DAO imlementation in Web UI and backend daemons.
4. Learn JRobin implementation of RRDtool(if needed). Implement support for XML, RRD and the report/graph data;

5. Conduct testing to verify the database mapping, operations and system integration, including integrating test file, regression test result and script for automated testing.

6. Provide developer-friendly documentation including list of achieved improvement, bug history and developing logs.

7. Create and commit patch of all changes to public repository. Ready for further improvement and bug-fix.

Through all of my work, I will keep in touch with my mentor and partners(if any), report progress to mentor on weekly basis and make change or improvement regarding instant feedback.

To finish up the migration of database access code in Hibernate/Spring fashion, including the database tables, RRD, graphs and reports, I plan to have the following outputs of project:

*DAO interfaces of tables with necessary database access and operating methods;

*Spring application context for DAO object management

*Implementation of all defined DAO operations in Hibernate framework.
*Create and commit patch of all changes on local repository. Push changes to the live repository.

*A developer-friendly documentation including list of achieved improvement, bug history and developing logs.

*Testing report, including integrating test file, regression test result and script for automated testing.

April 20 - May 13:
*Get to know mentors and OpenNMS community.
*Configure to setup the developing environment, including all needed plug-ins, Git version control tools, etc..
*Dive into the details of Hibernate, Spring, PostgreSQL and OpenNMS source code.
*Understand what proportion of project need to migrate to DAO. Begin to write skeleton of documentation.

May 15 - June 7:

*Go through the code and define all DTOs representing the data
*Understand how different layers coupled with each other in OpenNMS.
*Build configuration file. Usually this type of configuration can be automatically generated by Eclipse IDE with plugins.

June 8 - June 21:

*Find out the data access code in OpenNMS project, inject those access requests to DAO using Spring IoC fashion. Implement the previously defined DAO operations in Hibernate framework.
*Create Spring application context for DAO object management;

June 22 - June 28:
*Conduct testing to verify the database mapping, operations and system integration
*Learn JRobin implementation of RRDtool. Implement support for the report/graph data

June 29 - July 20:
*Integrate the previous work into latest version of OpenNMS project, make sure Web UI components and backend daemons works well with underlying logic implementation. (including debugging)
*Setup regular regression test, and learn the automated testing module.

*Conduct automated testing, write scripts to validate the configuration.

July 21 - August 2:

*Further test, report current bug issus and list achieved improvements. (keeping in touch with mentor)

*Commit project on the git, and publicated all the changes.
August 3 - August 15:

*Fixing the bugs.

*Finishing up the documentation and submit the final project.

Value to the community
*Map database columns to DAO, and provide methods/interface for data query, retrieval and operations on database.

* Provide a clear documentation of the work I've done, and give developer a clear view of how the system works.

* Further development on data mapping or table modification would be easy without expensive change of code.

Additionally, I think accomplishing this project does not mean I already reach the destination. I will still keep active working with open-source project and keep making my contribution for the community.