-->
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.  [ 2 posts ] 
Author Message
 Post subject: SQL Queries and Column Aliases
PostPosted: Tue May 04, 2010 8:10 am 
Newbie

Joined: Wed Apr 28, 2010 2:41 am
Posts: 3
Hi All,

We use Hibernate 3.3.1 for our application. For a new enhancement we require to execute Native SQL queries. I also require the column aliases. My code is as below:

Code:
Session session = (Session) getJpaTemplate().getEntityManagerFactory().createEntityManager().getDelegate();
      SQLQuery sqlQuery = session.createSQLQuery(query);
      
      List<Object[]> list = (List<Object[]>)sqlQuery.list();
      String[] colAliases = sqlQuery.getReturnAliases();
      
      for(int i=0; i<= colAliases.length; i++){
         System.out.println(colAliases[i]);
}


But it seems retrieving column aliases is not supported for SQL Queries. The following exception is thrown:

Quote:
java.lang.UnsupportedOperationException: SQL queries do not currently support returning aliases
at org.hibernate.impl.SQLQueryImpl.getReturnAliases(SQLQueryImpl.java:245)


Is there any other way that I can execute a SQL query and retrieve column names via Hibernate ? Or is JDBC the only option?


Thanks,
Midhun


Top
 Profile  
 
 Post subject: Re: SQL Queries and Column Aliases
PostPosted: Mon Aug 04, 2014 2:48 pm 
Newbie

Joined: Mon Oct 06, 2008 10:40 am
Posts: 12
Did you find an answer to this? I am running into the same issue.


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