Monday, September 15, 2008

Hibernate XDoclet Class From Table Generator

Still remember Hibernate XDoclet? In this post, we will create an AppGen in AppFuse. Imagine if we have a hundred of columns in our table in database and we have must to write a model of that class, it's fields, it's getter and setter one by one. So, here we start. In this example, our table (person) just have 3 columns.

Create folder util in src folder. In Eclipse, create source folder that refer to src/util. Create a package in that source folder named com.ndung.gen. For the first step, we must prepare our model template for class.template, field.template, getter.template, and also setter.template. We also have to prepare our jdbc properties to connect to our database.





After that, we create two classes named and TableInspector is used to inspect data type in each columns in table and map it in to Java class type. In another hand, ClassGenerator is used to write a Java model class file based on our template above.

Now, we create a main Java class named

Run that class above and refresh our project. Look in folder src/dao in package com.ndung.model. There is a model class named We must change XDoclet attribute for id from to become


Anonymous said...

dieta , диеты эффективные

Anonymous said...

диеты для похудения , диета

Anonymous said...

dieta , диеты для похудения