I've also reported this to "public" on Stack Overflow: http://stackoverflow.com/q/25603191/521799
Unfortunately, I don't have an OpenJDK account to report issues over there 2014-09-01 11:47 GMT+02:00 Lukas Eder <[email protected]>: > Hmm, to me, at first sight, this looks like a bug ("feature" ?) in the > Nashorn engine where from(String) is invoked, instead of > from(TableLike<?>...) > > - > http://www.jooq.org/javadoc/latest/org/jooq/SelectFromStep.html#from-java.lang.String- > - > http://www.jooq.org/javadoc/latest/org/jooq/SelectFromStep.html#from-org.jooq.TableLike...- > > I can reproduce this trivially with the following test program: > > *Java:* > > package org.jooq.nashorn.test; > > public class API { > > public static void test(String string) { > throw new RuntimeException("Don't call this"); > } > > public static void test(Integer... args) { > System.out.println("OK"); > } > } > > > *JavaScript / Nashorn:* > > var API = Java.type("org.jooq.nashorn.test.API"); > API.test(1); > > > The above program throws the RuntimeException. It looks like the problem > is related to overloading in combination with varargs. Removing the > overloaded test(String) method fixes the issue just like removing the > varargs. Knowing this, a workaround would be to avoid varargs calls and > explicitly wrap varargs arguments in arrays: > > var API = Java.type("org.jooq.nashorn.test.API"); > API.test([1]); > // ^ ^ array here > > > Or in your case: > > return dsl.select().from([Tables.EXAMPLE_TABLE]) > > // ^ ^ array here > > .orderBy(Tables.EXAMPLE_TABLE.NAME) > .limit(100) > .offset(0) > .fetch() > .intoMaps(); > > > This seems to work for me. > > I'll try to report this to the Nashorn people, looks like a very severe > Nashorn / Java interoperability issue, in my opinion! > > Cheers, and thanks for reporting! > Lukas > > 2014-09-01 11:22 GMT+02:00 Lukas Eder <[email protected]>: > > Hello Matt, >> >> Thanks for reporting this with details. I can reproduce your issue (works >> with Java, but not with Nashorn) and will be investigating. >> >> Cheers >> Lukas >> >> >> 2014-08-30 1:40 GMT+02:00 <[email protected]>: >> >> Hi, >>> >>> When using jOOQ within the Nashorn JavaScript engine, the subsequent >>> queries are surrounding the table names with quotation marks. It should be >>> noted that the existing jOOQ code *all works outside of the Nashorn >>> engine*, and we have a ton of code already in our code base >>> successfully using many different functions of jOOQ. We saw the following >>> blog entry: >>> >>> >>> blog.jooq.org/2014/06/06/java-8-friday-javascript-goes-sql-with-nashorn-and-jooq/ >>> >>> We decided to try to extend our implementation to allow JavaScript to >>> dynamically retrieve entries from our database. However, even when setting >>> the render name style as RenderNameStyle.AS_IS, the queries within the >>> Nashorn engine surrounds the table names with quotation marks and seems to >>> ignore the Settings altogether. >>> >>> [select * from "example_table" order by example_table.name asc limit ? >>> offset ?]; You have an error in your SQL syntax; check the manual that >>> corresponds to your MySQL server version for the right syntax to use near >>> '"example_table" order by example_table.name asc limit 100 offset 0' at >>> line 1 >>> var Tables = Java.type('com.jooq.generated.Tables'); >>> >>> function query() { >>> // THIS WORKS: >>> // return dsl.fetch('select * from example_table').intoMaps(); >>> >>> // THIS DOES NOT WORK: >>> settings.setRenderNameStyle(AS_IS); >>> var dsl = jooq.getAtomicDSLContextWithSetting(settings); >>> >>> return dsl.select().from(Tables.EXAMPLE_TABLE) >>> .orderBy(Tables.EXAMPLE_TABLE.NAME) >>> .limit(100) >>> .offset(0) >>> .fetch() >>> .intoMaps(); >>> } >>> >>> >>> Again, the jOOQ code works outside of the Nashorn engine. Only when >>> it's evaluated through Nashorn does this error surface. Here is some >>> sample code to run the Nashorn engine: >>> >>> ScriptEngineManager factory = new ScriptEngineManager(); >>> ScriptEngine engine = factory.getEngineByName("JavaScript"); >>> engine.put("jooq", this.jooqUtils); >>> >>> Settings s = new Settings(); >>> s.setExecuteLogging(true); >>> s.setRenderNameStyle(RenderNameStyle.AS_IS); >>> engine.put("settings", s); >>> >>> Invocable inv = (Invocable) engine; >>> engine.eval(file); >>> // invoke the global function named "query" >>> List<Map<String, Object>> results = (List<Map<String, Object>>) >>> inv.invokeFunction("query"); >>> if (results != null) { >>> Gson gson = new GsonBuilder().create(); >>> return gson.toJson(results); >>> } >>> >>> >>> Has anyone tried running jOOQ within Nashorn and/or ran into these >>> types of problems? >>> >>> Thanks, >>> >>> Matt >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "jOOQ User Group" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
