Change POJO name when generating from sleep mode

I would like to know how I can change the name of my POJO when creating it using sleep mode.

My tables have a naming convention: FR_ and TRN_. When creating a POJO, I would like to remove FR and TRN and add VO to the name.

For instance,

Table Name : FR_ACCOUNT_MST

POJO to create : accountMstVO

Thank you Varuna

+3
source share
3 answers

That's right, you should extend the DelegatingReverseEngineeringStrategy class (hibernate-tool.jar lib) and override the tableToClassName method .

The code below will rename FR_ACCOUNT_MST to FR_ACCOUNT_MSTVO.

, .

className + (.. com.mycompany.project.hibernate.FR_ACCOUNT_MST)

: http://www.cereslogic.com/pages/2008/08/05/hibernate-tools-tips-for-reverse/

package com.altenor.coffre.generated;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

public class CoffreReverseEngineeringStrategy extends DelegatingReverseEngineeringStrategy {

    public CoffreReverseEngineeringStrategy(ReverseEngineeringStrategy delegate) {
        super(delegate);
    }

    //add Base before class name
    public String tableToClassName(TableIdentifier tableIdentifier) {
          String className = super.tableToClassName(tableIdentifier);
          return className+"VO";
        }
}
+8

, hibernate.reveng.xml pojo:

<hibernate-reverse-engineering>
  <table-filter match-schema="CO" match-name="FR_ACCOUNT_MST"/>

  <table name="FR_ACCOUNT_MST" schema="CO" class="com.bonables.co.hibernate.pojo.accountMstVO" />

</hibernate-reverse-engineering>
+5

, Hibernate Tool . org.hibernate.cfg.reveng.ReverseEngineeringStrategy, .

+1

All Articles