-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Hibernate Oracle Problem: ORA-00907: missing right parenthes
PostPosted: Thu Sep 13, 2007 6:42 am 
Newbie

Joined: Wed Jul 04, 2007 9:06 am
Posts: 12
Hi all.

I'm using JBoss 4.2.1GA, and Oracle 10g, and attempting to perform a query.

I've been receiving a "ORA-00907: missing right parenthesis" error when attempting to perform the query.

Now this is apparently due to Hibernate using the 'as' keyword in the query - something that has been fixed in Hibernate 3.3.0ga.

So I updated these Hibernate libs in \server\default\lib:
hibernate-entitymanager.jar (3.3.1ga)
hibernate-annotations.jar (v 3.3.0ga)
hibernate-commons-annotations.jar (within Hibernate Annotations.rar\lib)
ejb3-persistence.jar (within Hibernate Annotations.rar\lib)
hibernate3.jar (v 3.2.5.ga)

But still get the same error. The query still contains the 'as' keyword.


The query...

I have two tables.

CSIUsers and CSIUserSurveys

There is a one-to-many mapping between
CSIUsers to CSIUserSurveys.

I'm trying to perform a query like to get users who haven't completed a survey before 'purchaseDate':

Query query = entityManager.createQuery("FROM " + CSIUser.class.getSimpleName()
+ " cu LEFT JOIN FETCH cu.csiUserSurveys us"
+ " WHERE cu.purchaseDate <= :purchaseDate"
+ " AND NOT EXISTS (SELECT us FROM cu.csiUserSurveys us WHERE us.csiUserId = cu.csiUserId)");


query.setParameter("purchaseDate", new java.sql.Date(cal.getTimeInMillis()), TemporalType.DATE);



That's it.

Can anyone help?


Last edited by DeanoUK on Fri Sep 14, 2007 10:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 8:59 am 
Newbie

Joined: Wed Jul 04, 2007 9:06 am
Posts: 12
To make it even simpler I've done:

Query query = entityManager.createQuery("FROM " + CSIUser.class.getSimpleName()
+ " cu LEFT JOIN cu.csiUserSurveys us"
+ " WHERE NOT EXISTS (SELECT us FROM cu.csiUserSurveys us WHERE us.csiUserId = cu.csiUserId)");

Still the same problem.

Getting desperate now!


Last edited by DeanoUK on Fri Sep 14, 2007 10:16 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 14, 2007 4:39 am 
Newbie

Joined: Wed Jul 04, 2007 9:06 am
Posts: 12
The output:

Code:
[[14 Sep 2007 15:43:52] DEBUG org.hibernate.util.JDBCExceptionReporter  - could n
ot execute query [select csiuser0_.CSI_USER_ID as CSI1_15_0_, csiusersur1_.CSI_U
SER_ID as CSI1_16_1_, csiusersur1_.SURVEY_TYPE_CODE as SURVEY2_16_1_, csiuser0_.
COMPANY_CODE as COMPANY2_15_0_, csiuser0_.EMAIL_ADDRESS as EMAIL3_15_0_, csiuser
0_.FAILED_LOGINS as FAILED4_15_0_, csiuser0_.LOCALE as LOCALE15_0_, csiuser0_.PA
SSWORD as PASSWORD15_0_, csiuser0_.PURCHASE_DATE as PURCHASE7_15_0_, csiuser0_.S
TATUS as STATUS15_0_, csiuser0_.USER_NAME as USER9_15_0_, csiuser0_.USER_PRIVILE
GE as USER10_15_0_, csiusersur1_.SURVEY_INVITE_DATE as SURVEY3_16_1_ from CSI_US
ERS csiuser0_ left outer join CSI_USER_SURVEYS csiusersur1_ on csiuser0_.CSI_USE
R_ID=csiusersur1_.CSI_USER_ID where  not (exists (select (csiusersur2_.CSI_USER_
ID, csiusersur2_.SURVEY_TYPE_CODE) from CSI_USER_SURVEYS csiusersur2_ where csiu
ser0_.CSI_USER_ID=csiusersur2_.CSI_USER_ID and csiusersur2_.CSI_USER_ID=csiuser0
_.CSI_USER_ID))]
java.sql.SQLException: ORA-00907: missing right parenthesis


From this it looks like the 'as' keyword isn't being used to alias a table - meaning the bug I thought it was is irrelevant. What could it be instead?

A native query doing the same thing works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 4:50 am 
Newbie

Joined: Wed Jul 04, 2007 9:06 am
Posts: 12
Can absolutely noone help with this on going issue?
I've had to file a bug.

http://opensource.atlassian.com/project ... e/HHH-2845


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 18, 2007 8:49 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 7:29 am
Posts: 36
Try using the Criteria API for this...

This might help....

http://www.javalobby.org/articles/hibernatequery102/


Top
 Profile  
 
 Post subject: Wrap the conditions in braces
PostPosted: Wed Sep 19, 2007 9:16 pm 
Newbie

Joined: Tue Sep 18, 2007 11:13 am
Posts: 8
All u need is to wrap the the first condition in "where" clause in braces

Query query = entityManager.createQuery("FROM " + CSIUser.class.getSimpleName()
+ " cu LEFT JOIN FETCH cu.csiUserSurveys us"
+ " WHERE (cu.purchaseDate <= :purchaseDate)"
+ " AND NOT EXISTS (SELECT us FROM cu.csiUserSurveys us WHERE us.csiUserId = cu.csiUserId)");


This should work.


Top
 Profile  
 
 Post subject: Re: Hibernate Oracle Problem: ORA-00907: missing right parenthes
PostPosted: Wed Feb 26, 2014 7:27 am 
Newbie

Joined: Wed Feb 26, 2014 7:20 am
Posts: 1
Hi,
I'm trying to execute the next query using CriteriaBuilder and CriteriaQuery interfaces:
Code:
select DES_EVE_CAT, COUNT(*) from KWXS.TKWXSSAU where ( DES_EVE_CAT in ('asociaServicioMejorado') ) and ( TIM_EVENTO<=TO_DATE('31/10/2014','DD/MM/YYYY') ) group by DES_EVE_CAT;


My code to represent the sql expression is like this:
Code:

CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<TkwxssauWrapper> cq = cb.createQuery(TkwxssauWrapper.class);

Root <Tkwxssau> tkwxssau = cq.from(Tkwxssau.class);
List<Predicate> predicates = new ArrayList<Predicate>();

Expression<String> expDesEveCat = tkwxssau.get("desEveCat");
//predicates.add(expDesEveCat.in(consumptionTypes));

predicates.add(cb.equal(expDesEveCat, EventoAplicacion.EVENTOAPLICACION_REGISTER_SOA_SERVICE_CONSUMPTION));

Path<Date> dateTimEventoPath = tkwxssau.get("timEvento");

if (date1 != null && date2 != null){
predicates.add(cb.between(dateTimEventoPath, date1, date2));
} else if (date1 != null) {
predicates.add(cb.greaterThanOrEqualTo(dateTimEventoPath, date1));
} else if (date2 != null) {
predicates.add(cb.lessThanOrEqualTo(dateTimEventoPath, date2));
}

Path<Long> desEveCatPath = tkwxssau.get( "desEveCat" );

//    cq.multiselect(desEveCatPath, cb.count(tkwxssau));

cq.select(cb.construct(TkwxssauWrapper.class, desEveCatPath, cb.count(tkwxssau)));
cq.where(cb.and(predicates.toArray(new Predicate[predicates.size()])));
cq.groupBy(tkwxssau.get("desEveCat"));

TypedQuery<TkwxssauWrapper> q = entityManager.createQuery(cq);
List<TkwxssauWrapper> results = q.getResultList();


It seems the code is right, but when I'm debugging it, it finishes with next error :

org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:311)
at
Caused by: java.sql.SQLException: ORA-00907: missing right parenthesis

The sentence generated by my code is this :

select new com.bbva.kwxs.gobsoabacksearch.TkwxssauWrapper(generatedAlias0.desEveCat, count(generatedAlias0)) from Tkwxssau as generatedAlias0 where ( generatedAlias0.desEveCat in (:param0) ) and ( generatedAlias0.timEvento<=:param1 ) group by generatedAlias0.desEveCat

if I translate it to sql to execute in the Oracle SQL Database like this,

Code:
select DES_EVE_CAT, COUNT(generatedAlias0) from KWXS.TKWXSSAU as generatedAlias0 where ( generatedAlias0.DES_EVE_CAT in ('asociaServicioMejorado') ) and ( generatedAlias0.TIM_EVENTO<=TO_DATE('31/10/2014','DD/MM/YYYY') ) group by generatedAlias0.DES_EVE_CAT;


shows the followed error :

Error: ORA-00933: SQL command not properly ended
SQLState: 42000
ErrorCode: 933



I have seen that Oracle does not accept the alias clause AS: from KWXS.TKWXSSAU as generatedAlias0, and I think this is my error.

Is there any possibility to remove the alias or generate the alias without AS clause?

I've checked my configurations files and I 've seen that the mapping to Oracle is correctly indicated in the persintence.xml file :
Code:
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>


I have been looking for the answer for other pages and I still haven't found any solution.


Thanks for you help.

Regards.

José Pascual


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.