mxc4 wrote:
Hi Max,
I want to customise the output of the code generator. According to my understanding I can do quite a lot of customisation to the code produced with the velocity template.
Yes - that is true, but I personally prefer the basic generation code as it is much more feature complete - and produces much better readable code than the velocity macros (IMHO)
mxc4 wrote:
I want to produce two sets of object. The basic value objects and then a "concrete" class which I can use to decorate the value objects with extra functionality. For example I would like the objects to implement an interface with the following signature
You do now that hbm2java support this natively with the generated-class attribute ? (and the more new "generate-concrete-empty-classes")
Quote:
public Object getNaturalKey();
public int getPrimaryKey();
The natural key will be used to sort collections of the object with the comparable interface. Also I use a lot of JTables to display the objects. Getting meta-information such as column names, column classes, number of fields etc requires a lot of repetitive coding. I was hoping to use the template to produce this for me and then just use a generic tablemodel to request this info from the wrapped value objects.
hmm - why not use normal reflection for that ?
Oh well - if I were you I would try to simply extend the BasicRenderer and add a generateNaturalAndPrimaryKey() method to it - much easier in my world - and you get the full benefits of hbm2java instead of relying on the much weaker velocity based version. (but that is just me ;)