Have you tried to extend the ReverseMappingTool so that you can intercept the generated code rather than write it to a file? ... I'm not sure how feasible this might be as I'm writing from my phone.
On Fri, Dec 6, 2013 at 3:35 PM, Aron L <a.lurie+o...@gmail.com> wrote: > Hi All, > > I've managed to get ReverseMappingTool running from within a plain-old Java > method. Using the following: > > -------------------------------------------------------- > > JDBCConfiguration result = new JDBCConfigurationImpl(); > result.setDBDictionary(xyz); > result.setConnectionURL(xyz); > result.setConnectionDriverName(xyz); > result.setConnectionUserName(xyz); > result.setConnectionPassword(xyz); > > Options rmOpts = new Options(); > String argString = "-Log DefaultLevel=INFO -metaDataFactory jpa() -metadata > none"; > rmOpts.setFromCmdLine(StringUtils.split(argString, " ")); > > try { > ReverseMappingTool.run(result, new String[0], rmOpts); > } catch (Exception e) { > e.printStackTrace(); > } > > -------------------------------------------------------- > > This successfully writes Java files reflective of the specified database to > the directory that my code is running in, as expected. > > However, I would much prefer to have the Java generated returned in a map > as > a String, than written to a file. I see a way of changing the code slightly > to make this happen: The method "recordCode" called by run on [1] below can > take a Map, and if the Map is there, it will write the code that I want to > that map. So if a variant of run(...) is added that allows the user to pass > a map which is then forwarded to that method, then the user will get the > code back. > > [1] > > http://grepcode.com/file/repository.springsource.com/org.apache.openjpa/com.springsource.org.apache.openjpa/1.1.0/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java#2017 > > Does anyone see a better way to do this, that doesn't involve changing the > code? And if not, should I submit this customization as a patch? > > Thanks, > Aron > > > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/Using-ReverseMappingTool-run-to-generate-Java-strings-tp7585730.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > -- *Rick Curtis*