2014-10-10 4 views
0

ClassA를 확장하고 SampleInterface를 구현하는 사용자 지정 DAO를 생성하려고합니다. SampleInterface에는이 DAO를 생성하는 동안 구현되어야하는 메소드가 있습니다. 또한 내가 생성하는 DAO의 명명 규칙은 클래스 이름 끝에 DAO가 있어야하지만 "홈"이 아니어야합니다. 최대 절전 모드 도구는 결국 기본적으로 홈으로 DAO 클래스를 생성하기 때문입니다.최대 절전 모드 도구를 사용하여 사용자 지정 DAO를 생성하는 방법

내 테이블 이름은 Employee, Address, Salary이고 생성 된 엔티티는 com.mycompany.model 패키지에 있습니다. 현재 나는 모든 주석과 매핑을 포함하는 Address, Employee, Salary Entities를 가지고 있습니다. 아래의 리버스 엔지니어링 전략을 사용하여 AddressDAO, EmployeeDAO 및 SalaryDAO를 생성하려고합니다.

다음은

public class DAOReverseEngineeringStrategy extends 
      DelegatingReverseEngineeringStrategy { 

     public DAOReverseEngineeringStrategy(ReverseEngineeringStrategy delegate) { 
      super(delegate); 
      // TODO Auto-generated constructor stub 
     } 

     @Override 
     public Map tableToMetaAttributes(final TableIdentifier tableIdentifier) { 
      Map<String, MetaAttribute> metaAttributes = super 
        .tableToMetaAttributes(tableIdentifier); 
      if (metaAttributes == null) { 
       metaAttributes = new HashMap<String, MetaAttribute>(); 
      } 

      MetaAttribute attributeExtends = new MetaAttribute("extends"); 
      attributeExtends.addValue("ClassA"); 
      metaAttributes.put("extends", attributeExtends); 

      MetaAttribute attributeImpl = new MetaAttribute("implements"); 
      attributeImpl.addValue("SampleInterface"); 
      metaAttributes.put("implements", attributeImpl); 

      MetaAttribute attributeImport = new MetaAttribute("extra-import"); 
      attributeImport.addValue("com.mycompany.ClassA"); 
      attributeImport.addValue("com.mycompany.SampleInterface"); 
      attributeImport.addValue("com.mycompany.model.*"); 
      metaAttributes.put("extra-import", attributeImport); 

      return metaAttributes; 
     } 
    } 

감사합니다 내 리버스 엔지니어링 전략 클래스입니다.

답변

0

아직 열리지는 않지만 어쨌든 내 대답을 공유하고 싶습니다.

나는 Reverse Engineering Strategy 클래스로 시도하지 않았지만, dao/daoHome.ftl에서 ftl (무료 마커 템플리트) 파일을 사용했다.