Joget Workflow v6 RC2 Released
Check out the latest Joget Workflow v6 RC2 for many new features and improvements in user experience (UX), app maintainability and performance.
Sometime, you may want to have your own Hibernate entity and dao to access extra database table in your plugin. It is very simple to achieve that by adding the following file and class to your plugin.
Similar to development in Spring + Hibernate, a application context file is required for your plugin. In my sample plugin, I created a productsApplicationContext.xml as below
In the application context, I created 2 beans. Bean "productSessionFactory" is to initialize a session factory with the hibernate mapping file. Bean "productsDao" is to initialize the dao object of my sample plugin.
Next, we need a Hibernate Mapping file. In my sample plugin, it is /org/joget/sample/products/model/Products.hbm.xml. It mapped the POJO "org.joget.products.model.Product" with "valu_products" table.
You need a utility class to initialized your application context and allow you to retrieve the bean object.
You need to orverride
findSession method in
ProductsDaoImpl as compared to joget version 4.
After you implemented your POJO and dao class, you should be able to use your dao in your plugin as following. Please refer to the attached sample plugin for POJO and dao implementation.
In this KB:sample plugin, you are able to add, delete and list product by the following JSON API.
To list all products,