openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aron Lurie <a...@cambridgesemantics.com>
Subject Re: Using ReverseMappingTool.run(...) to generate Java strings?
Date Sun, 08 Dec 2013 21:50:18 GMT
Rick,
Thanks for the idea. I did some reading into that, and while there is some
potential there to extend ReverseMappingTool and override the recordCode()
method, the static run(...) method itself is responsible for instantiating
the class [1]. So, without copying all of that method into the subclass, no
dice.

[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#1987

Thanks,
Aron


On Sat, Dec 7, 2013 at 12:54 PM, Rick Curtis <curtisr7@gmail.com> wrote:

> 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+ojpa@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*
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message