The column name 'true' is not valid #890

Closed
yeradis opened this Issue Aug 11, 2014 · 7 comments

Comments

Projects
None yet
2 participants
@yeradis

yeradis commented Aug 11, 2014

I was trying to filter a column which type is BIT (i'm using SQLServer)
Something like this:

mapeos.activo.isTrue()

or :

mapeos.activo.eq(true)

raise an sql exception:

The column name 'true' is not valid

the generated SQL is:

and IDS_MAPEOS.ACTIVO = true

and should be :

and IDS_MAPEOS.ACTIVO = 'true'

or

and IDS_MAPEOS.ACTIVO = 1
@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Aug 11, 2014

Member

Do you have the literal serialization enabled?

Member

timowest commented Aug 11, 2014

Do you have the literal serialization enabled?

@yeradis

This comment has been minimized.

Show comment
Hide comment
@yeradis

yeradis Aug 11, 2014

Sorry the delay
This is my config:

<plugin>
                <groupId>com.mysema.querydsl</groupId>
                <artifactId>querydsl-maven-plugin</artifactId>
                <version>${querydsl.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>export</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jdbcDriver>net.sourceforge.jtds.jdbc.Driver</jdbcDriver>
                    <jdbcUrl>jdbc:jtds:sqlserver://xxxxxxxxxxx</jdbcUrl>
                    <jdbcUser>xxxxx</jdbcUser>
                    <jdbcPassword>xxxxxxx</jdbcPassword>
                    <packageName>com.sql.model.querydsl</packageName>
                    <targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
                    <exportBeans>true</exportBeans>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sourceforge.jtds</groupId>
                        <artifactId>jtds</artifactId>
                        <version>${jtds.version}</version>
                    </dependency>
                </dependencies>
 </plugin>

The literal serialization should be enabled?

yeradis commented Aug 11, 2014

Sorry the delay
This is my config:

<plugin>
                <groupId>com.mysema.querydsl</groupId>
                <artifactId>querydsl-maven-plugin</artifactId>
                <version>${querydsl.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>export</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jdbcDriver>net.sourceforge.jtds.jdbc.Driver</jdbcDriver>
                    <jdbcUrl>jdbc:jtds:sqlserver://xxxxxxxxxxx</jdbcUrl>
                    <jdbcUser>xxxxx</jdbcUser>
                    <jdbcPassword>xxxxxxx</jdbcPassword>
                    <packageName>com.sql.model.querydsl</packageName>
                    <targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
                    <exportBeans>true</exportBeans>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sourceforge.jtds</groupId>
                        <artifactId>jtds</artifactId>
                        <version>${jtds.version}</version>
                    </dependency>
                </dependencies>
 </plugin>

The literal serialization should be enabled?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Aug 11, 2014

Member

I am asking because the error looks like that. How does your serialized query look like? The one that Querydsl provides to JDBC.

Member

timowest commented Aug 11, 2014

I am asking because the error looks like that. How does your serialized query look like? The one that Querydsl provides to JDBC.

@yeradis

This comment has been minimized.

Show comment
Hide comment
@yeradis

yeradis Aug 12, 2014

Hello

from(QIdsHotel.idsHotel).
                where(QIdsHotel.idsHotel.activo.isTrue(),
                        QIdsHotel.idsHotel.codsubcanal.eq(getContext().getSubChannel()))
                .list(QIdsHotel.idsHotel);

the "from" is:

protected SQLQuery from(Expression<?> expression) {
        return query().from(expression);
}

This is the generate query:

select IDS_HOTEL.CODIGOHOT, IDS_HOTEL.ETP, IDS_HOTEL.PASSWORD, IDS_HOTEL.CODSUBCANAL, IDS_HOTEL.TIPO_PRECIO, IDS_HOTEL.LAST_REQUEST, IDS_HOTEL.CODIGOHOT_EXT, IDS_HOTEL.USUARIO, IDS_HOTEL.ACTIVO
from dbo.IDS_HOTEL IDS_HOTEL
where IDS_HOTEL.ACTIVO = true and IDS_HOTEL.CODSUBCANAL = 'CECI'

yeradis commented Aug 12, 2014

Hello

from(QIdsHotel.idsHotel).
                where(QIdsHotel.idsHotel.activo.isTrue(),
                        QIdsHotel.idsHotel.codsubcanal.eq(getContext().getSubChannel()))
                .list(QIdsHotel.idsHotel);

the "from" is:

protected SQLQuery from(Expression<?> expression) {
        return query().from(expression);
}

This is the generate query:

select IDS_HOTEL.CODIGOHOT, IDS_HOTEL.ETP, IDS_HOTEL.PASSWORD, IDS_HOTEL.CODSUBCANAL, IDS_HOTEL.TIPO_PRECIO, IDS_HOTEL.LAST_REQUEST, IDS_HOTEL.CODIGOHOT_EXT, IDS_HOTEL.USUARIO, IDS_HOTEL.ACTIVO
from dbo.IDS_HOTEL IDS_HOTEL
where IDS_HOTEL.ACTIVO = true and IDS_HOTEL.CODSUBCANAL = 'CECI'

@timowest timowest added the bug label Aug 12, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Aug 14, 2014

Member

There should be questions marks for true and 'CECI'. Are you sure this query is generated by Querydsl?

Member

timowest commented Aug 14, 2014

There should be questions marks for true and 'CECI'. Are you sure this query is generated by Querydsl?

@timowest timowest added this to the 3.4.3 milestone Aug 14, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Aug 14, 2014

Member

I added now a pull request, but it fixes the Querydsl behaviour only for cases where you have literal serialization on, by default prepared statement bindings are used though.

For prepared statement bindings booleans work in any case.

Member

timowest commented Aug 14, 2014

I added now a pull request, but it fixes the Querydsl behaviour only for cases where you have literal serialization on, by default prepared statement bindings are used though.

For prepared statement bindings booleans work in any case.

@timowest timowest closed this in #896 Aug 15, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Aug 31, 2014

Member

Released in 3.4.3

Member

timowest commented Aug 31, 2014

Released in 3.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment