Menu

How do I set $extendsClass

2007-10-11
2013-04-25
  • David Goodenough

    In the bean.java.vm files there is a facility to make the generated bean extend a class.  The code checks for the presence of a value in $extendsClass.  But I can not find anywhere that $extendsClass gets set, it is not present in any of the source code (or at least that is what grep tells me).

    The relevant bit of bean.java.vm reads:-

    public class $beanClass
    #if ($extendsClass)
        extends $extendsClass
    #end
        implements GeneratedBean
    #if ($implementsClasses)
        #foreach( $implements in $implementsClasses )$implements#end
    #end

    I suppose I would expect it to be set somewhere like section 3/8 of sql2java.properties "Generated Source" code, but I can not spot anywhere that looks right.

     
    • Alain Fagot Béarez

      I am personally thinking of two ways to set it:

      1- in the includes/table.include.vm if it has to be known by all the templates managing tables;
      2- in the bean.java.vm itself if it is (as its seems to be) the place where it is used.

      You could use some definition like

      #set ( $extendsClass = Base$table.asCoreClass() )
      or
      #set ( $extendsClass = AbstractBean )

      the former one, if you get one base class generated for each table (by adding a new template);
      the latter one, if you have some abstract class all generated classes will extend.

      If you would like it to be set according to more complex rules... you may have to wait for the scripting functionality of version 3.0 to be released.

      Hope this helps,
      Alain.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.