Part I. Getting started

Part II. UML modeling

Part III. Project glossary

Part IV. BPMN toolset

Part V. Project management

Part VI. Modeling toolset

Part VII. ArchiMate tools

Part VIII. Team collaboration

Part IX. Code engineering

Part X. Database design and engineering

Part XI. Advanced modeling toolset

Part XII. Document production

Part XIII. Business modeling

Part XIV. Business rule

Part XV. Agile development

Part XVI. Wireframe

Part XVII. Impact analysis

Part XVIII. CMMN toolset

Part XIX. SoaML modeling

Part XX. Design animation

Part XXI. IDE Integration

Part XXII. Interoperability and integration

Part XXIII. Process simulation

Part XXIV. Zachman and BMM

Part XXV. Appendix A - Application Options

Part XXVI. Appendix B - Project Options

Part XXVII. Appendix C

 

PersistentManager and Transaction

PersistentManager is used to manage database connection, state of the persistent objects and transaction when the application is running. A database transaction is a unit of the application. It is used to keep integrity of your data in database. Our Persistent Library provides a transaction API for you to create, commit and rollback the transaction for your application.

Start Transaction

When you need to start a transaction, you need to get the session from the PersistentManager and call the beginTransaction function (PersistentManager.instance().getSession().beginTransaction();). Here is a sample:

PersistentTransaction t = PersistentManager.instance().getSession().beginTransaction();

Commit Transaction

After you have inserted/updated/deleted data, you can call the commit function of the transaction object to commit your changes to Database.

t.commit();

Rollback Transaction

In case there are any exception, you can call the rollback function to cancel all the operation.

t.rollback();

Sample Code

The following is an example of using the transaction API.

private Course fireOK() throws PersistentException {
   PersistentTransaction t = SchoolSystemPersistentManager.instance().getSession().beginTransaction();
   try {Course lCourse = CourseFactory.createCourse();
      lCourse.setTitle(getTitleTextField().getText());
      lCourse.setDescription(getDescriptionTextField().getText());
      lCourse.setTeacher(_teacher);
      _teacher.save();
      t.commit();
      return lCourse;
   } catch (Exception e) {
      e.printStackTrace();
      t.rollback();
   }
   return null;
}

Related Resources

The following resources may help you to learn more about the topic discussed in this page.

 
3. Generating ORM code from class diagram Table of Contents 5. Using ORM Qualifier

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.OK