-->
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.  [ 3 posts ] 
Author Message
 Post subject: Exception when i include brace({) character
PostPosted: Tue Aug 28, 2012 11:47 am 
Newbie

Joined: Tue Aug 28, 2012 11:40 am
Posts: 2
Hi,

can any help in this issues when i used '{' character? can we solve this issuse in hibernate?
I am using the native query
manager.createNativeQuery(query,WorkGroupEntity.class);

Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: Unmatched braces for alias path [select wk.* from workgroup wk where UPPER(wk.WKG_NAME) = 'W{G' AND wk.BE_ID in (select be.be_id from Business_entity be where be.ORG_ID = 1)]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:624)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:74)
at com.etrali.dke.administration.dao.WorkGroupDAO.findAll(WorkGroupDAO.java:173)

name.toUpperCase() = w{G
businessEntity.getOrganization().getId() = 1

String query = "select wk.* from workgroup wk where UPPER(wk.WKG_NAME) = '" +
name.toUpperCase() + "' AND wk.BE_ID in " +
"(select be.be_id from Business_entity be where be.ORG_ID = " +
businessEntity.getOrganization().getId() + ")";


Top
 Profile  
 
 Post subject: Re: Exception when i include brace({) character
PostPosted: Wed Aug 29, 2012 3:28 am 
Newbie

Joined: Tue Aug 28, 2012 11:40 am
Posts: 2
I solved this problem by using setparameter for query object.

String query = "select wk.* from workgroup wk where UPPER(wk.WKG_NAME) = ? AND wk.BE_ID in " +
"(select be.be_id from Business_entity be where be.ORG_ID = " +
businessEntity.getOrganization().getId() + ")"

Query q1 = manager.createNativeQuery(query,WorkGroupEntity.class);
q1.setParameter(1, "W{G");

Because while parsing the createNativeQuery it is used to check the opened (or) closed braces so it will throw exception.


Top
 Profile  
 
 Post subject: Re: Exception when i include brace({) character
PostPosted: Sat Feb 16, 2013 2:00 pm 
Newbie

Joined: Thu Aug 30, 2012 9:07 am
Posts: 3
Hi there,

I have the same problem, but I can not use the same solution as yours, because in my case I am using native sql query when I am restoring backup archives of my system.
So it is a huge inserts which are generated dynamically based on backup XML file. I am parsing XML-s and further I am creating inserts based on xml data, and then executing those inserts by the native sql query. And when there is a '{' or '}' character - the system is crashing.
So for such a functional using 'setParameter()' solution is not acceptable.

Is there any other way to solve this bug? This is CRITICALLY IMPORTANT for me.
Please share with your ideas.

Thanks,
Harut.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.