Coder Social home page Coder Social logo

lsql's People

Contributors

gitter-badger avatar romanroe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsql's Issues

IDE settings leading to merge conflicts

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.

Quotes are not escaped

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";");

StackOverflowError when calling Row.toString after groupByIds(...)

    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)
    . . .

NPE when get-Method without set-Method is used

Code

public String getSomething() { return "abcdef"; }

Exception

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:?]

Generate Guice Module

CLI should generate a Module containing all the generated DAOs if di:guice is provided as command line argument

Use more than one parameter in one line

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

Maven repository issues

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

SQL Exception when migratin from 0.21.5 to 0.23.0

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

Improve Logging

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.

ClassCastException in LongConverter

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);
    }
}

NPE in IdGroupedRowCreator

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)

Expressionless Exception

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:?]

[lsql-cli] Missing converter leads to incomplete error message

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

CLI name inconsistencies

  • For a column 'VALIDFROM' (two words, but not separated) the CLI generates an interface ValidFromInteger which is stored in a file called ValidfromIngeger.
  • For a column 'VALIDTO' it is the other way around: an interface ValidtoInteger stored in a file called ValidToIngeger
  • In the result-row-class for 'VALIDFROM' ValidFromInteger is used, for 'VALIDTO' it is ValidToInteger. This is consistent but ValidToInteger does not exist (see bullet 2).

public final instead of private fields in row classes

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?

Missing blank new line

Generated Java source files have no blank new line at the end. Git complains about that ...

SQL-Exception on save with sql server dialect

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

Exception in PojoMapper

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;

}

Using a Converter with a PojoTable Fails

  • Code fails in the first line, claiming that uploadActive in AutoJob has the wrong type.
  • 2nd line, assigning the Converter is never executed
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]

LSqlFile not reading files from jar

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.

BUILD FAILURE

Hi there.
Your build is failure, can you please fix it?

Missing license in pom.xml

In the pom.xml is no license declared. So license checker like gradle-license-report fail to report correctly.

Name Collision in CLI with PascalCase Statement Names

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.