Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Active Objects MSSQL boolean issue

Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2013

I've had a number of issues with various databases using Active Objects. I was hoping AO would magically handle db abstraction but bygones...

I'm probably not taking the right approach here and can use your thoughts:

Query.select().where("MY_THING_ID = ? AND SOME_PERMISSION = TRUE", someObject.getID()));

which works for mysql and postgres but throws the following in mssql:

Database:
	- name:Microsoft SQL Server
	- version:11.00.3128
	- minor version:0
	- major version:11
Driver:
	- name:jTDS Type 4 JDBC Driver for MS SQL Server and Sybase
	- version:1.2.2

java.sql.SQLException: Invalid column name 'TRUE'.

Is there a db agnostic way to use TRUE? Something like ActiveObjects.True that handles the variance in databases. Thanks

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

6 votes
Answer accepted
Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2013

rather than true I needed to use Boolean.TRUE. This seems to work for all dbs.

Query.select().where("MY_THING_ID = ? AND SOME_PERMISSION IS ?", someObject.getID(), Boolean.TRUE));

3 votes
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2013

I feel your pain, I've had the same issues with Active Objects...

Without being able to test the code at the moment, I would try to inject the value instead of hardcoding it:

Query.select().where("MY_THING_ID = ? AND SOME_PERMISSION = ?", someObject.getID(), true));

If this still doesn't work, I would try to use "IS" instead:

Query.select().where("MY_THING_ID = ? AND SOME_PERMISSION IS ?", someObject.getID(), true));

Hope this helps.

Cheers
Remo

Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2013

Thanks for the input. That hasn't worked for me yet but I'll do a clean build to be sure. Interestingly using IS changes the error to "java.sql.SQLException: Incorrect syntax near '@P1'." That leads to MSSQL requires () around the arugment which leads to another error so I need to dig into it a bit.

0 votes
Remo Siegwart September 25, 2013

I feel your pain, I've had the same issues with Active Objects...

Without being able to test the code at the moment, I would try to inject the value instead of hardcoding it:

Query.select().where("MY_THING_ID = ? AND SOME_PERMISSION = ?", someObject.getID(), true));

If this still doesn't work, I would try to use "IS" instead:

Query.select().where("MY_THING_ID = ? AND SOME_PERMISSION IS ?", someObject.getID(), true));

Hope this helps.

Cheers
Remo

TAGS
AUG Leaders

Atlassian Community Events