After upgrading H2 database version from 1.3.171 to 1.4.187, my select statement failing with the jdbc error code [90022-187]. I'm, using Spring 4 and Hibernate 4.3.5.
Error Trace :
Function "BUS_ENTY_GUID" not found; SQL statement:
select * from ( select consumerin0_.CNSMR_INTNT_SID as CNSMR_IN1_0_0_, busentity1_.BUS_ENTY_SID as BUS_ENTY1_4_1_, intentuser2_.USR_SID as USR_SID1_10_2_ where consumerin0_.OWNR_ENTY_NM=busentity1_.BUS_ENTY_GUID(+) and consumerin0_.USR_EXTRNL_ID=intentuser2_.MAG_GUID(+) and lower(consumerin0_.ORD_ID)=lower(?) and lower(intentuser2_.USR_LAST_NM)=lower(?) ) where rownum <= ? [90022-187]
Kindly help in resolving the issue
H2 no longer supports the "old style" Oracle outer join syntax. You will have to use "outer join" instead.
Thanks Thomas for you help!
I was using org.hibernate.dialect.OracleDialect, hence conversion of the query has older style joins. Now I have changed it to Oracle10gDialect which is working fine.
Use -Dh2.oldStyleOuterJoin=true to support older syntax.
Visit http://www.h2database.com/javadoc/org/h2/engine/SysProperties.html
Related
I have a very simple SQL query I need to run
SELECT `id`, `{Document id}` FROM `test`.`test` LIMIT 10;
where {Document id} is a column name. Whenever I run it through MariaDB JDBC, it fails with error unknown escape sequence. From my understanding {CALL ...} is used to call stored procedure with a JDBC CallableStatement.
How do I escape it? I want JDBC to treat it as literal string without special meaning. \ didn't work for me.
As mentioned in deleted answer by #a_horse_with_no_name, there is setEscapeProcessing. But it's not supported by a lot of connectors (example MariaDB).
I have confirmed this issue using mariadb-java-client-2.2.5. It is not an issue with mysql-connector-java-5.1.44 so you might want to report this issue to MariaDB.
Following the suggestion by #JoopEggen in the comments above, I got it to work with MariaDB JDBC by adding sessionVariables=sql_mode=ANSI_QUOTES to the connection string and using
ResultSet rs = st.executeQuery("SELECT \"{Document id}\" FROM test.test");
We have a legacy app which uses Hibernate 3.0.3. We do unit testing with HSQLDB. One of the queries that is generated by Hibernate looks like this:
select
transactio0_.REASON_ID as REASON1_0_,
transactio0_.DESCRIPTION as DESCRIPT2_93_0_,
transactio0_.REASON_NAME as REASON3_93_0_
from APPS.MTL_TRANSACTION_REASONS transactio0_
where transactio0_.REASON_ID=54
and transactio0_.NVL (transactio0_.disable_date, NOW() + 1 DAY) > NOW()
Note that the schema name "transactio0_" is prepended to the NVL function. Why? How can we configure Hibernate so that does not do that?
The next question deals with the version of HSQLDB that we are using. We're currently using HSQLDB 2.2.8 and would like to move up to HSQLDB 2.3.2.
The above query works fine with HSQLDB 2.2.8 but fails in HSQLDB 2.3.2 with an "invalid schema name" error. Is there any way that we can configure HSQLDB 2.3.2 so that it can successfully execute the query like HSQLDB 2.2.8 does?
The generated SQL looks strange and is certainly incorrect SQL. The transactio0_ is a table alias and shouldn't be prepended to any function name.
Perhaps the selected Hibernate dialect is not the HSQLDB dialect.
In any case, this is an old version of Hibernate and needs to be used with a version of HSQLDB that is closer to its time of release.
Regarding configuring HSQLDB to accept the malformed name, it shouldn't be possible as the original behavior was fixed because it was too lax and accepted incorrect SQL.
I had a similiar problem. To fix this you need to put "()" together with the function name. For example:
and NVL (transactio0_.disable_date, NOW() + 1 DAY) > NOW()
change to
and NVL(transactio0_.disable_date, NOW() + 1 DAY) > NOW()
in another words, remove the space character.
I have query for MS-SQL and Oracle but I want to convert into Jooq .I also trying somthing like this DSL.connectByRoot(field) But I am unable to find this solution . The main issue is that in Oracle we use clause connect by prior but its not available in MS-SQL.
MS-SQL QUERY:
WITH tempTable(ppCode, pCode) AS (
SELECT DefaultProcessDependent.PriorProcessCode, ProcessCode
FROM DefaultProcessDependent
WHERE DefaultProcessDependent.ProcessCode = ?
AND DefaultProcessDependent.FolderType = ?
UNION ALL
SELECT nplus1.PriorProcessCode, nplus1.ProcessCode
FROM DefaultProcessDependent as nplus1, tempTable
WHERE tempTable.ppCode = nplus1.ProcessCode
)
SELECT ppCode FROM tempTable
ORACLE QUERY:
Select processCode
from DefaultProcessDependent
start with DefaultProcessDependent.ProcessCode = ?
connect by prior processCode = priorProcessCode
Anyone help me please...................
Thanks
Common table expressions will be supported with jOOQ 3.4. jOOQ will also emulate CONNECT BY for other databases, but that won't be available in jOOQ 3.4 yet.
I am currently learning JPA with Hibernate, using maven as well.
It happens so that I need to use named query's in my orm.xml with a input parameter in the set-clausule of an update statement. It gives me an error that a parameter can only be used in the WHERE or HAVING clausule.
After reading several pages I found out that JPA 2.0 does not support it, but JPA 2.1 does.
See this, bulletpoint 4.6.4
So I changed my orm.xml and persistence.xml to the 2.1 schemes as well, but it still gives and error. Although it still runs perfectly, I hate seeing error signs.
Anyone Any idea? I am using Eclipse Kepler 4.3.2
Pictures of orm.xml, persistence.xml, pom.xml and my project properties can be found here
I have the same problem, code works fine and it should with JPA 2.1 (Final Release)
http://download.oracle.com/otn-pub/jcp/persistence-2_1-fr-eval-spec/JavaPersistence.pdf In chapter4.6.4 (page 182) find this text (my highlight):
"Input parameters can only be used in the WHERE clause or HAVING clause of a query or as the new value for an update item in the SET clause of an update statement. "
But eclipse validation still take input parameter in update query as an error...
Maybe we should raise a bug against org.eclipse.persistence.jpa.jpql
The following query should work:
<named-query name = "Artikel.findByWord">
<query>
UPDATE Artikel a
SET a.verkoopprijs = a.verkoopprijs * :percentage
</query>
</named-query>
with the corresponding java code:
em.createNamedQuery("Artikel.findByWord")
.setParameter("percentage", 10)
.executeUpdate();
I'm trying to track the amount of redo being generated during a database session with the following query:
SELECT a.name, b.VALUE
FROM v$statname a, v$mystat b
WHERE a.statistic# = b.statistic# AND a.name = 'redo size';
This query works directly in SQL*Plus and Toad, but I get an ORA-00911 exception using JDBC, and I've narrowed it down to the "statistic#" column name.
How do I get around this?
The column name statistic# is not the problem.
My bet is that you also send the terminating ; from inside your Java program.
But you may not include the the ; when executing a SQL statement through JDBC (at least not in Oracle and some other DBMS).
Remove the ; from your SQL String and it should be fine.
put it in double quotes - that should let you call a field anything in Oracle
Switch on JDBC logging, check your driver documentation for how to do this. In the JDBC log you see the actual statement prepared and executed in the DB. This eliminates one possible cause for the error.