w11k / lsql Goto Github PK
View Code? Open in Web Editor NEWJava SQL Database Library
Home Page: https://github.com/w11k/lsql/blob/master/README.md
License: Apache License 2.0
Java SQL Database Library
Home Page: https://github.com/w11k/lsql/blob/master/README.md
License: Apache License 2.0
Hi,
in my optinion any IDE files shouldn't be a part of the project. In my case they lead to merge conflicts when updating from the upstream. Could it be possible do remove all iml files and add them to .gitignore?
Thank you in advance.
CLI does not escape double quotes in the sql statement on embedding the statement to the generated java code.
select * from "SCHEMA"."TABLE";
will produce Java code like super(lSql,"SELECT * FROM "SCHEMA"."TABLE";");
at java.util.regex.Pattern$Node.<init>(Pattern.java:3347)
at java.util.regex.Pattern$CharProperty.<init>(Pattern.java:3684)
at java.util.regex.Pattern$CharProperty.<init>(Pattern.java:3684)
at java.util.regex.Pattern$BmpCharProperty.<init>(Pattern.java:3712)
at java.util.regex.Pattern$BmpCharProperty.<init>(Pattern.java:3712)
at java.util.regex.Pattern$Single.<init>(Pattern.java:3740)
at java.util.regex.Pattern.newSingle(Pattern.java:3305)
at java.util.regex.Pattern.atom(Pattern.java:2197)
at java.util.regex.Pattern.sequence(Pattern.java:2046)
at java.util.regex.Pattern.expr(Pattern.java:1964)
at java.util.regex.Pattern.compile(Pattern.java:1665)
at java.util.regex.Pattern.<init>(Pattern.java:1337)
at java.util.regex.Pattern.compile(Pattern.java:1022)
at java.lang.String.replaceAll(String.java:2162)
at com.google.common.base.Objects.simpleName(Objects.java:156)
at com.google.common.base.Objects.toStringHelper(Objects.java:118)
at com.w11k.lsql.Row.toString(Row.java:128)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at java.util.AbstractCollection.toString(AbstractCollection.java:458)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at java.util.AbstractMap.toString(AbstractMap.java:523)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at com.google.common.base.Objects$ToStringHelper.toString(Objects.java:397)
at com.w11k.lsql.Row.toString(Row.java:128)
. . .
public String getSomething() { return "abcdef"; }
Caused by: java.lang.NullPointerException at com.w11k.lsql.PojoMapper.setPropertyAccessible(PojoMapper.java:161) ~[lsql-core-0.23.0.jar:?] at com.w11k.lsql.PojoMapper.<init>(PojoMapper.java:45) ~[lsql-core-0.23.0.jar:?] at com.w11k.lsql.PojoMapper.getFor(PojoMapper.java:20) ~[lsql-core-0.23.0.jar:?] at com.w11k.lsql.query.PojoQuery.<init>(PojoQuery.java:19) ~[lsql-core-0.23.0.jar:?] at com.w11k.lsql.sqlfile.LSqlFile$2.createQueryInstance(LSqlFile.java:73) ~[lsql-core-0.23.0.jar:?] at com.w11k.lsql.sqlfile.LSqlFile$2.createQueryInstance(LSqlFile.java:70) ~[lsql-core-0.23.0.jar:?] at com.w11k.lsql.statement.AbstractSqlStatement.query(AbstractSqlStatement.java:33) ~[lsql-core-0.23.0.jar:?]
CLI should generate a Module containing all the generated DAOs if di:guice is provided as command line argument
When trying to execute a statement with more then one parameter as an one liner fails. An Example:
Table "link"
id | a | b |
---|---|---|
1 | foo | bar |
2 | baz | bum |
This statement fails:
--deleteWhereAandB
DELETE FROM link WHERE a = /*(*/ ' ' /*)*/ AND b = /*(*/ ' ' /*)*/;
This statement succeed:
--deleteWhereAandB
DELETE FROM link WHERE a = /*(*/ ' ' /*)*/
AND b = /*(*/ ' ' /*)*/;
Both statements are called with
getlSqlFile().statement("deleteWhereAandB").execute("a", "foo", "b", "bar);
With the first statement the exception comes with following error Unused query parameter [a]
.
The LSql Version used is 0.6.23
The maven repository provided doesn't contain the latest versions of the library. If the repository has changed, it would be nice if it was updated in the documentation
This is what we get:
Caused by: java.sql.SQLException: Cannot update identity column 'id'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2893) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2335) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:638) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:613) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:572) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:727) ~[jtds-1.3.0.jar:1.3.0]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[HikariCP-2.5.1.jar:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[HikariCP-2.5.1.jar:na]
at com.w11k.lsql.Table.executeUpdate(Table.java:487) ~[lsql-core-0.23.0.jar:na]
at com.w11k.lsql.Table.updateWhere(Table.java:229) ~[lsql-core-0.23.0.jar:na]
... 44 common frames omitted
Currently it returns an int.
Other methods like getFloat do return an Object Type
Trace logging in com.w11k.lsql.statement.SqlStatementToPreparedStatement tells me the statement name but not the path to the file. With a lot of statements called 'selectById' it is hard to figure out which log entry is for which statement.
Hi,
would it be possible to support ps.setQueryTimeout()?
thank you in advance.
LongConverter tries to cast the value to an Int instead of Long.
public class LongConverter extends Converter {
@Override
protected void setValue(LSql lSql, PreparedStatement ps, int index, Object val) throws SQLException {
ps.setLong(index, (Integer) val);
}
}
Caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
at com.google.common.collect.ImmutableMultimap$Builder.put(ImmutableMultimap.java:169)
at com.google.common.collect.ImmutableListMultimap$Builder.put(ImmutableListMultimap.java:167)
at com.google.common.collect.Multimaps.index(Multimaps.java:1781)
at com.google.common.collect.Multimaps.index(Multimaps.java:1727)
at com.w11k.lsql.IdGroupedRowCreator.groupByColumn(IdGroupedRowCreator.java:80)
If a converter throws an exception there will be no information about the query executed or the column. Please catch and wrap the exception and give some additional information to the developer.
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_102]
at java.lang.Long.parseLong(Long.java:601) ~[?:1.8.0_102]
at java.lang.Long.parseLong(Long.java:631) ~[?:1.8.0_102]
at java.text.DigitList.getLong(DigitList.java:195) ~[?:1.8.0_102]
at java.text.DecimalFormat.parse(DecimalFormat.java:2051) ~[?:1.8.0_102]
at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1869) ~[?:1.8.0_102]
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1514) ~[?:1.8.0_102]
at java.text.DateFormat.parse(DateFormat.java:364) ~[?:1.8.0_102]
at com.***.server.core.database.StringToDateConverter.getValue(StringToDateConverter.java:49) ~[***-server-4.3.0-SNAPSHOT.jar:?]
at com.w11k.lsql.converter.Converter.getValueFromResultSet(Converter.java:68) ~[lsql-core-0.23.0.jar:?]
at com.w11k.lsql.query.AbstractQuery.extractEntity(AbstractQuery.java:252) ~[lsql-core-0.23.0.jar:?]
When a converter is missing in the used configuration, the error message does not show the table name and column which causes the error. Here a stack trace of my actual error
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: No converter for SQL type 'TIME'.
at com.w11k.lsql.cli.java.JavaExporter.fetchMetaDataForAllTables(JavaExporter.java:62)
at com.w11k.lsql.cli.java.JavaExporter.<init>(JavaExporter.java:39)
at com.w11k.lsql.cli.Main.<init>(Main.java:55)
at com.w11k.lsql.cli.Main.main(Main.java:80)
Caused by: java.lang.IllegalArgumentException: No converter for SQL type 'TIME'.
at com.w11k.lsql.converter.ConverterRegistry.getConverterForSqlType(ConverterRegistry.java:24)
at com.w11k.lsql.LSql.getConverterForSqlType(LSql.java:302)
at com.w11k.lsql.LSql.getConverterForTableColumn(LSql.java:352)
at com.w11k.lsql.Table.fetchMeta(Table.java:597)
at com.w11k.lsql.Table.<init>(Table.java:51)
at com.w11k.lsql.LSql.tableBySqlName(LSql.java:183)
at com.w11k.lsql.cli.java.JavaExporter.fetchMetaDataForAllTables(JavaExporter.java:59)
... 3 more
At least the statement result classes has private fields that get assigned in the constructor only. And there is a getter to read them.
In my project we use public final fields and I have to change a lot of code to make use of the generated statement and result classes. Could you please change the fields to public final. Or is there a reason I don't see not to do it?
Generated Java source files have no blank new line at the end. Git complains about that ...
When we are using sql server dialect and use the save or update method there will be this exception. In #18 you suggest to use Column#setIgnoreOnUpdate(true)
. But we need to set this on every table we use. Better when LSql sets automatically on primary key columns ignoreOnUpdate=true
Caused by: java.sql.SQLException: Cannot update identity column 'id'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2893) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2335) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:638) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:613) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:572) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:727) ~[jtds-1.3.0.jar:1.3.0]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[HikariCP-2.5.1.jar:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[HikariCP-2.5.1.jar:na]
at com.w11k.lsql.Table.executeUpdate(Table.java:487) ~[lsql-core-0.23.0.jar:na]
at com.w11k.lsql.Table.updateWhere(Table.java:229) ~[lsql-core-0.23.0.jar:na]
... 44 common frames omitted
Not always but sometimes the PojoMapper throws an IllegalAccessException. After server restart it works for a while but the exception started to appear again.
Unfortunately there is no information about the field name.
Lombok's Data annotation adds getter and setter methods for all fields. RequiredArgsConstructor in this case adds a constructor without parameters.
java.lang.IllegalAccessException: Class com.w11k.lsql.PojoMapper can not access a member of class xyz.ABC with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102) ~[?:1.8.0_40]
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296) ~[?:1.8.0_40]
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288) ~[?:1.8.0_40]
at java.lang.reflect.Method.invoke(Method.java:490) ~[?:1.8.0_40]
at com.w11k.lsql.PojoMapper.setValue(PojoMapper.java:70) ~[lsql-core-0.28.7.jar:?]
at com.w11k.lsql.query.PojoQuery.setValue(PojoQuery.java:41) ~[lsql-core-0.28.7.jar:?]
at com.w11k.lsql.query.AbstractQuery.extractEntity(AbstractQuery.java:282) ~[lsql-core-0.28.7.jar:?]
at com.w11k.lsql.query.AbstractQuery.access$000(AbstractQuery.java:29) ~[lsql-core-0.28.7.jar:?]
at com.w11k.lsql.query.AbstractQuery$2.call(AbstractQuery.java:136) ~[lsql-core-0.28.7.jar:?]
at com.w11k.lsql.query.AbstractQuery$2.call(AbstractQuery.java:133) ~[lsql-core-0.28.7.jar:?]
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54) ~[rxjava-1.0.16.jar:1.0.16]
at com.w11k.lsql.query.AbstractQuery$3.call(AbstractQuery.java:158) ~[lsql-core-0.28.7.jar:?]
at com.w11k.lsql.query.AbstractQuery$3.call(AbstractQuery.java:150) ~[lsql-core-0.28.7.jar:?]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable.subscribe(Observable.java:8264) ~[rxjava-1.0.16.jar:1.0.16]
at rx.Observable.subscribe(Observable.java:8231) ~[rxjava-1.0.16.jar:1.0.16]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:433) ~[rxjava-1.0.16.jar:1.0.16]
at rx.observables.BlockingObservable.first(BlockingObservable.java:160) ~[rxjava-1.0.16.jar:1.0.16]
at com.w11k.lsql.query.AbstractQuery.toList(AbstractQuery.java:96) ~[lsql-core-0.28.7.jar:?]
package xyz;
import com................Month;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@RequiredArgsConstructor
class ABC {
public Month timeId;
public String saStatus;
public Date dueDate;
}
table = this.lSql.table("tAutoJob", AutoJob.class);
table.getTable().column("uploadActive").setConverter(new AutoJobBooleanConverter());
Caused by: java.lang.IllegalArgumentException: Field ....AutoJob#uploadActive has the wrong type: 'boolean'. Expected: 'java.lang.String'
at com.w11k.lsql.PojoMapper.checkConformity(PojoMapper.java:124) ~[lsql-core-0.21.8.jar:na]
at com.w11k.lsql.PojoTable.<init>(PojoTable.java:27) ~[lsql-core-0.21.8.jar:na]
at com.w11k.lsqtable(LSql.java:172) ~[lsql-core-0.21.8.jar:na]
at....AutoJobDao.<init>(AutoJobDao.java:42) ~[main/:na]
Provide means to ignore specific columns
Hi,
I think lsql should respect storesUpperCaseIdentifiers when fetching meta data of the table.
kind regards,
Dragan
Hi,
we got the following exception, but only in validation phase (mvn test runs).
java.lang.IllegalArgumentException: URI is not hierarchical at java.io.File.<init>(File.java:418) at com.w11k.lsql.sqlfile.LSqlFile.parseSqlStatements(LSqlFile.java:72) at com.w11k.lsql.sqlfile.LSqlFile.<init>(LSqlFile.java:44) at com.w11k.lsql.LSql.readSqlFileRelativeToClass(LSql.java:112) at com.w11k.lsql.LSql.readSqlFile(LSql.java:125) at com.w11k.lsql.guice.LSqlDao.getlSqlFile(LSqlDao.java:26)
It seems, that reading the sql file does not work, it's included in a jar.
In the pom.xml there is a newer version defined, but there no release is available . Our problem currently is, we get a newer Guava version into our project and this breaks using a current lsql version.
Hi there.
Your build is failure, can you please fix it?
In the pom.xml is no license declared. So license checker like gradle-license-report
fail to report correctly.
Newest version in Maven repo: 0.23.0
Newest version according to git repo: 0.26.0
When I name query GetData both the query class and the result class will be named GetData. The query class has an asterisks import and uses the result class just by name. But as this name is the same as the query class, the query class will be returned.
Simple solution: use a full qualified name for the return type of the query class
Hi,
please use slf4j instead of logback. This dependency should be declared "weakly", because the user of lsql may or may not provide a logging framework, e.g. when used in a container. See http://www.slf4j.org/faq.html#maven2 for details.
regards,
dz
Is it possible, to reload SQL Files by Jrebel?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.