Customizing ID generator

Besides the built-in strategies for generating ID, users can implement how ID will be generated by customizing an ID generator.

  1. In Class Diagram, create the ID generator class, and stereotype it as ORM ID Generator.
    To open column specification
    An ID generator class
  2. 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
     Click Open Specification... from the pop-up menu
  3. In the Column Specification dialog box, select the class in the ID Generator.
    Select an ID generator in Column Specification dialog box
    Select an ID generator in Column Specification dialog box
  4. Click OK to confirm.
  5. 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
 
5. Controlling primary key values using ID generator Table of Contents 7. Drawing View
 

Product

Try this feature with

Visual Paradigm for UML

Technical Support

Have technical issues or suggestions? Please contact Visual Paradigm Support Team.

Sales Support

Have questions related to registration, licensing or payment? Feel free to contact Visual Paradigm Sales Team.

Discussion Forum

Share your suggestions of opinions at VP Discussion Forum.