openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aron L <a.lurie+o...@gmail.com>
Subject Using ReverseMappingTool.run(...) to generate Java strings?
Date Fri, 06 Dec 2013 21:35:44 GMT
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.

Mime
View raw message