Re: 3.3.1 to 4.0 migration
Thomas Fox <[email protected]> Thu, 2 Jul 2015 03:03:21 +0200 (CEST)
| Newsgroups | gmane.comp.jakarta.turbine.torque.user |
|---|---|
| Message-ID | <[email protected]> |
Helge Weissig wrote: > I forgot about the HTML filter this group uses=E2=80=A6 pardon the crappy= formatting.=20 > Here is a text-only version: > > Our code base is heavily invested in some of the functionality removed fr= om torque 4.0=20 > and I was wondering if any one had some advice on a migration path: > >=091. We make extensive use of village records obtained via=20 > BasePeer.doSelect(Criteria), for example.=20 > Those results could probably be considered a view of the data > and I am wondering if that would be the correct/recommended/best= approach. If you are using this to read data only, have a look at the RecordMapper fu= nctionality. A record mapper maps DB Columns to an object. You can use diff= erent record mappers for the same table (e.g. it can be passed in through S= omePeer.doSelect(Criteria, RecordMapper<TT>), so have different object repr= esentations. For a generic village-record-like representation, see org.apac= he.torque.om.mapper.ObjectListMapper (personally I do not like this represe= ntation, put perhaps it serves your needs). Views (now supported !) are als= o a more db-centric option.=20 >=092. We have added our own caching implementation=20 > (configurable via the schema definition) to the Object.vm=20 > and Peer.vm templates. I have read through the new generator doc= umentation=20 > and the customization part of the OR Mapping Reference=20 > (https://db.apache.org/torque/torque-4.0/documentation/orm-refer= ence/customizing-generation.html) > but I don=E2=80=99t seem to be able to find the relevant informa= tion=20 > to put it all together. Basically, I would like to override one = or more templates. > I think I know how to specify that in an outlet, but do I also n= eed the control configuration > in the conf directory? The maven plugin (we use maven) has confi= guration parameters=20 > for overrideConfigDir and overrideConfigPackage=E2=80=A6 do I ne= ed to set those? Have you checked the code-gen tutorial (http://db.apache.org/torque/torque-= 4.0/documentation/tutorial/orm/index.html) for a basic understanding ? Also, there is an example in the torque test project (https://svn.apache.or= g/repos/asf/db/torque/torque4/trunk/torque-test/src/main/torque-gen) which = basically does what you want, i.e. overrides the Peer template (adding @Sup= pressWarnings annotations). The torque generation config which invokes this= can be found in https://svn.apache.org/repos/asf/db/torque/torque4/trunk/t= orque-test/pom.xml lines 183ff. To be more specific: Yes, you need at least an empty control configuration. You need to set either overrideConfigDir or overrideConfigPackage, dependin= g whether the additional templates can be found in the file sytsem or in th= e classpath. Please ask again if you cannot get it working. Although more complicated :-= (, the new generator is much more extensible than the old one. In the curre= nt trunk, you can even use groovy templates :-) >=093. This is more of a maven question, maybe, alas I have the feeling > it isn=E2=80=99t actually possible to implement through it, but = is there a way > to skip the code generation steps if the schema sources have not= changed? Sorry, this is not any more possible. The problem is to reliably find out w= hether the file has changed (e.g. some OS do not change the change date of = a file when it is copied). I have seen more than one situation where schema= changes did not get picked up because of this option, so my personal recom= mendation is not to rely on such a mechanism. Also, mvn generate is typical= ly not executed often while developing, so long generation times should not= slow down development too much. However, if you still want to use it, you can patch the Mojo class in the T= orque maven plugin, this should not be too difficult (please share if you c= hoose to do it). >=094. I know how to configure logging for the generator, but the switch be= tween loglevel > WARN and INFO is quite severe. Is there a way to log at INFO lev= el but only to a file,=20 > not to the console? We use log4j throughout our project. Yes, check the log4j configuration documentation. Basically you need to ove= rride the log4j configuration file and use two appenders, one file appender= and one console appender, with different log levels. The log4j configurati= on needs to be in the classpath /org/apache/torque/generator/log4j.properti= es and it must have a higher classpath priority than the torque-generator.j= ar (I am currently not sure how to achieve this using maven, the last resor= t is patching the generator) Good luck! Thomas