sentence stringlengths 1 1.38k | label stringclasses 3
values |
|---|---|
Thanks to that we can easily create statements that are not known at compile time. | o |
URL_http://www.querydsl.com/ [Querydsl] and URL_http://www.jooq.org [jOOQ] are two popular choices. | p |
Note: I work for the company behind Querydsl. | o |
Which one do you use? | o |
:). | o |
JOOQ is maybe a better choice for hardcore SQL development, but Querydsl has a simpler API and supports also other backends (JPA, JDO, Lucene, Mongodb etc. | p |
); I am also in the company behind Querydsl. | o |
We use Querydsl SQL in a few of our in house projects. | o |
I have no personal experience of jooq but I have heard that it is quite ok. | o |
I do hardcore SQL development. | o |
I've used both JOOQ and QueryDSL. | o |
Both are quite good but I prefer the latter. | p |
The code and project management is more mature. | o |
The problem with QueryDsl is that you can't use it as a pure query generator as it does not give you the generated query itself. | o |
It will generate the query and execute it for you too. | o |
You can't get one without another. | o |
@abhinav-sarkar Querydsl supports that, just not as directly as JOOQ. | o |
@TimoWestkmper can you point me to the methods to do that? | o |
I went through the javadocs and the code but couldn't find anything. | o |
You can for example describe the query as a subquery and then serialize it via the SQLSerializer URL_http://www.querydsl.com/static/querydsl/2.9.0/apidocs/com/my sema/query/sql/SQLSerializer.html#serialize%28com.mysema.query.QueryMetadata,% 20boolean%29 If you want a more convenient way to get the SQL String and bindin... | o |
Querydsl and jOOQ seem to be the most popular and mature choices however there's one thing to be aware of: Both rely on the concept of code generation, where meta classes are generated for database tables and fields. | p |
This facilitates a nice, clean DSL but it faces a problem when trying to create queries for databases that are only known at runtime, like in the OP's example above. | p |
While jOOQ supports a String based approached there are some quirks. | o |
The documentation of Querydsl doesn't mention whether it's possible to not use code generation. | o |
Please correct me if I'm wrong. | n |
URL_https://github.com/fuzzylollipop/sqlck [SQL-Construction-Kit] is a very flexilble, no dependency framework. | p |
Development recently moved from code.google.com to github. | o |
It is also available from Maven Central Repository via Sonatype. | o |
It's a pity they support only mssql, oracle and sql99. | n |
No mysql, firebird etc. | o |
Also no documentation visible... | o |
SQL99 is a generic implementation that will should work with any database. | o |
If you add support for specific databases, and sent a pull request, I can guarantee it will get into the mainline code base. | o |
Thanks. | o |
Can you make some examples, please? | o |
Don't want to dig into the code just to find out how it works at all. | p |
about SQL99: I could tell you one thousand reasons why that
be true. | o |
And two thousand reasons, why it
Take a simple select 1, which also comes in at least these flavours: select 1 from dual, select 1 from sysibm.dual, select 1 from sysibm.sysdummy1, select 1 from information_schema.system_users... Oh don't get me started :-). | p |
I can recommend URL_http://www.jooq.org [jOOQ] . | p |
It provides a lot of great features, also a intuitive DSL for SQL and a extremly customable reverse- engineering approach. | p |
jOOQ effectively combines complex SQL, typesafety, source code generation, active records, stored procedures, advanced data types, and Java in a fluent, intuitive DSL. | n |
Do you use it? | o |
How do you find it? | o |
I use it to generate custom source code from DDL. | o |
It's working great!. | p |
Hibernate Criteria API (not plain SQL though, but very powerful and in active development): CODESNIPPET_JAVA1 . | p |
The problem is that it doesn't map to SQL as I understand, right? | o |
this doesn't generate SQL and is a nightmare to debug when it doesn't follow the rule of least astonishment ( doesn't work as expected ). | o |
It does generate SQL (at the end) and it surprises no one. | o |
Benefit -- it is portable across databases. | p |
+1 Upvoted again to level up. | p |
I don't know why this was downvoted. | n |
After all, it's become the standard way of doing this with JPA, even if it's a bit verbose... | n |
What is the level of query complexity that you achieved to reach with the JPA Criteria API, without making the query utterly unreadable? | o |
Do you have an example of a nested select in an IN / EXISTS clause, or of a self-join using aliases for the Sale entity, etc? | o |
I'm curious. | o |
Comments do not give much space to provide the examples, but you're welcome to review them at URL_http://docs.jboss.org/hibernate/core/3.5/reference/en/html/querycriteria.html . | p |
URL_http://db.apache.org/ddlutils/ [ddlutils] is my best choice: URL_http://db .apache.org/ddlutils/api/org/apache/ddlutils/platform/SqlBuilder.html [http:// db.apache.org/ddlutils/api/org/apache/ddlutils/platform/SqlBuilder.html] here is create example(groovy): CODESNIPPET_JAVA1 . | p |
SQL parser library for Java. | o |
Is there a good open-source Java library for parsing SQL statements? | o |
If possible, it should be customizable or flexible enough to also be able to parse (or at least ignore) vendor-specific syntax (such as Oracle tablespace definitions or MySQL's LIMIT clause). | p |
If not, strict adherence to the SQL standard is also fine. | p |
I need this for two things:
providing an SQL interface to a non-SQL database (mapping to internal API calls)
rewriting SQL before it goes to the actual database (e.g. | o |
Oracle) . | o |
URL_http://jparsec.codehaus.org . | o |
how is this question not constructive? | o |
what's wrong with you, Stackoverflow? | o |
URL_http://www.antlr3.org/grammar/list.html [ANTLR] has an ANSI SQL grammar available. | o |
You can use that to create your own parser. | o |
Why use ANTLR when you can implement your own parser generator? | o |
Why generate your own parser generator when you can use ANTLR? | o |
Any links to how one can use Antlr SQL Grammar to parse these queries? | o |
I looked at the grammar of some PL/SQL Parsers as well as Lexers and Parsers but was unable to fathom how to use one. | p |
Would appreciate any links. | p |
You feed the grammar to ANTLR, which spits out the lexer/parser classes that you'll then compile and run. | o |
The best source I can think of is the ANTLR reference: URL_http://www.amazon.com/Definitive-Antlr-Reference-Domain-Specific - Programmers/dp/0978739256/ref=sr_1_1?ie=UTF8&qid=1327847925&sr=8-1. | p |
The link [ URL_http://www.antlr.org/grammar/list](http://www.antlr.org/grammar/list ) is broken. | n |
Does anyone know where the sql grammar is located? | o |
We're up to ANTLR 4 now. | o |
Perhaps the old grammars don't run on the new version. | o |
URL_http://www.antlr3.org/grammar/list.html . | o |
URL_http://jsqlparser.sourceforge.net/ [JSqlParser] . | o |
If you need a parser there should be a parser in the code base of URL_http://db.apache.org/derby/ [Apache-Derby] . | o |
with vendor-specific SQL** You may want to look at the URL_http://java.sun.com/javase/6/docs/api/java/sql /Connection.html#nativeSQL%28java.lang.String%29 [.native()] method on the jdbc Connection object which you can pass it vendor neutral queries that will get postprocessed into vendor specific queries. | o |
That native() method looks interesting. | p |
Are there any examples as to how it can be used? | o |
What kind of conversions are possible there? | o |
URL_http://www.sqlparser.com/sql-parser-java.php [General-SQL-Parser-for-Java] is not open source, but is exactly what you are looking after. | n |
The best sql parser for Java +1. | p |
Try URL_http://zql.sourceforge.net/ [Zql] . | o |
zql is good for basic queries but when you try to parse a query that contains join statement, it blows up. | n |
so i don't suggest it. | o |
Hibernate uses ANTLR for sql and hql parsing. | o |
JSqlParser is also a good option.although it has some bugs(or some features not implemented) while parsing oracle pl/sql.see its forum for detail. | p |
so if you're parsing oracle pl/sql, ANTLR is recommended. | p |
btw, anltr is under BSD. | o |
What you want to do with the parsed SQL? | o |
I can recommend a few Java implementation of Lex/Yacc ( URL_http://byaccj.sourceforge.net/ [BYACC/J] , URL_http://www2.cs.tum.edu/projects/cup/ [Java-Cup] ) that you can use an existing SQL grammar with. | p |
If you want to actually do something with the resulting parsed grammar, I might suggest looking at URL_http://db.apache.org/derby/ [Derby] , an open source SQL database written in Java. | p |
Is the SQL parser used in Derby available as an independent JAR ? | o |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.