demonz demonz
demonz demonz

Reputation: 649

silly mistake o' mine: hibernate SQL throwing invalid character

Disclaimer: This was just a silly mistake i made. Did not close it because maybe some other person did the same thing and might find it useful.

two tables:

COR_RADICADO_OFICIO:
- num_radicado (pk)
- ano_radicado (pk)

(I know, composite pks are evil but it's a legacy db, not my design ;) )

and

COR_RESPUESTA_OFICIO:
- num_radicado (text)(fk)
- ano_radicado (number)(fk)
- requiere_respuesta (number)

In hibernate:

createSQLQuery("select * from COR_RADICADO_OFICIO where REQUIERE_RESPUESTA = 399 " +
"and concat(concat(num_radicado , '_'),  ano_radicado) not  in "+ 
"(select concat(concat(num_radicado , '_), ano_radicado) from COR_RESPUESTA_OFICIO);" );

if i execute this query directly on oracle, it works fine, however hibernate throws

java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

Tried replacing 'concat' function with '||' and got the same error.

Any ideas how to fix that one? (besides creating a view).

Upvotes: 2

Views: 1578

Answers (1)

meredrica
meredrica

Reputation: 2563

try removing the semicolon maybe? The error you are getting doesn't say invalid SQL, it says invalid character which is something different altogether.

Upvotes: 7

Related Questions