Customizing ID generator
Besides the built-in strategies for generating ID, users can implement how ID will be generated by customizing an ID generator.
- In Class Diagram, create the ID generator class, and stereotype it as ORM ID Generator.

|
An ID generator class
|
- Rigth click on the primary key column that you want to select an ID generator for and select Open Specification... from the pop-up menu.

|
Click Open Specification... from the pop-up menu
|
- In the Column Specification dialog box, select the class in the ID Generator.

|
Select an ID generator in Column Specification dialog box
|
- Click OK to confirm.
- After generated ORM code, look for the ID generator class and implement the generate method by return an Integer or Long.
/**
* Licensee: VP Development
* License Type: Purchased
*/
import java.io.Serializable;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.id.IdentifierGenerator;
public class ProductIDGenerator implements IdentifierGenerator {
public Serializable generate(SessionImplementor session, Object object) {
//TODO: Implement Method
throw new UnsupportedOperationException();
}
}
//ORM Hash:fae9faed19486e5f2b85c9d2d0d52cd9