0

I have this query, here taken from debug inspect while running:

SELECT columndata.* FROM columndata  WHERE record_id  IN (SELECT record_id FROM columndata WHERE  columnmeta_id = 2 AND numeric_value = 777793989) ORDER BY ID

It returns 16 rows.

I have this code:

List<ColumnData> colData = ColumnData.findBySQL("SELECT columndata.* FROM columndata "
    + " WHERE record_id  IN (SELECT record_id FROM columndata WHERE " 
    + " columnmeta_id = " + "? AND numeric_value = ?) ORDER BY ID", pkColMetaId, pk);

colData is [], i.e. it maps nothing.

Here are the records:

"ID"|"COLUMNMETA_ID"|"TABLEMETA_ID"|"RECORD_ID"|"STRING_VALUE"|"BLOB_VALUE"|"BOOLEAN_VALUE"|"NUMERIC_VALUE"|"DATE_VALUE"|"CREATED_AT"|"UPDATED_AT"
"2325"|"55"|"1"|"1220"|"97"|||||"2018-06-10 08:17:42.26"|"2018-06-10 08:19:08.225"
"2326"|"56"|"1"|"1220"|"121"|||||"2018-06-10 08:17:42.263"|"2018-06-10 08:18:31.777"
"2327"|"57"|"1"|"1220"|"1"|||||"2018-06-10 08:17:42.264"|"2018-06-10 08:18:22.629"
"2328"|"59"|"1"|"1220"|"Queen"|||||"2018-06-10 08:17:42.265"|"2018-06-10 08:18:41.101"
"2329"|"270"|"1"|"1220"|"Tyler"|||||"2018-06-10 08:17:42.266"|"2018-06-10 08:18:20.587"
"2330"|"1"|"1"|"1220"|"David's Project"|||||"2018-06-10 08:17:42.267"|"2018-06-11 18:10:26.841"
"2331"|"2"|"1"|"1220"||||"777793989"||"2018-06-10 08:17:42.268"|"2018-06-10 08:17:42.268"
"2332"|"3"|"1"|"1220"||||||"2018-06-10 08:17:42.268"|"2018-06-10 08:17:42.268"
"2333"|"4"|"1"|"1220"|||"TRUE"|||"2018-06-10 08:17:42.269"|"2019-01-27 15:11:44.651"
"2334"|"5"|"1"|"1220"|||"FALSE"|||"2018-06-10 08:17:42.27"|"2018-06-10 08:17:42.27"
"2335"|"238"|"1"|"1220"|||||"2018-06-30 00:00:00.0"|"2018-06-10 08:17:42.271"|"2018-06-10 08:19:00.776"
"2336"|"60"|"1"|"1220"||||||"2018-06-10 08:17:42.271"|"2018-06-10 08:17:42.271"
"2337"|"61"|"1"|"1220"|"Ret"|||||"2018-06-10 08:17:42.272"|"2018-06-10 08:19:06.413"
"2338"|"62"|"1"|"1220"||||||"2018-06-10 08:17:42.273"|"2018-06-10 08:17:42.273"
"2339"|"63"|"1"|"1220"|"3567"|||||"2018-06-10 08:17:42.274"|"2018-06-10 08:19:27.175"
"2340"|"64"|"1"|"1220"|||||"2018-06-10 00:00:00.0"|"2018-06-10 08:17:42.282"|"2018-06-11 18:10:49.678"

Here is ColumnData class:

import org.javalite.activejdbc.Model;
import org.javalite.activejdbc.annotations.Table;

@Table(value = "COLUMNDATA") 
public class ColumnData extends Model {

}

Where as this:

            List<ColumnData> allCol = ColumnData.findAll(); 

Returns all 709 rows

I also tried uppercase as defined in the ColumnData class annotation

SELECT COLUMNDATA.* FROM COLUMNDATA  WHERE RECORD_ID  IN (SELECT RECORD_ID FROM COLUMNDATA WHERE  COLUMNDATA_ID = ? AND NUMERIC_VALUE = ?) ORDER BY ID

Same result

Ideas?

  • What database, do you have a dataset, what is the value of the variables when evaluated, what language, what language, what happens when you run the query directly? Are you using same user when testing? – Michael Feb 18 '19 at 22:36
  • I am using H2. Java 8. When I run directly it produces the results I added. The user is the same across runtime, SQL query console and debug. – user3442828 Feb 18 '19 at 22:41
  • Please, post your Java code for class `ColumnData`. Also, experiment with `Base.findAll()` and see if you get the results - post that too. – ipolevoy Feb 19 '19 at 03:04
  • What happens if you hard code the ? to values you expect and do a straight query in your code? – Michael Feb 19 '19 at 23:19
  • If I hard code the ? it produces exactly the same result, an empty List – user3442828 Feb 20 '19 at 11:31
  • This turns out to be a corruption inside Eclipse IDE somewhere. It has become a bloated, slow and unreliable IDE. A clean install of Eclipse and everything magically works – user3442828 Feb 25 '19 at 09:41

0 Answers0