-->
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.  [ 1 post ] 
Author Message
 Post subject: how to use dynamic instantiation in native sql query?
PostPosted: Thu Feb 04, 2010 1:22 pm 
Newbie

Joined: Thu Feb 04, 2010 12:50 pm
Posts: 6
Consulting Chapter 7 of "Hibernate in Action" (https://forums.hibernate.org/viewtopic.php?f=1&t=965074), I used the following method:

Code:
String queryString = "SELECT A.id as (C.id), A.name as (C.name) from table_a A;"

Query query = HibernateUtil.getSession().createSQLQuery(queryString).addEntity("C", CCC.class);


CCC.java is something like this:

Code:
@Entity
public class CCC
{
@Id
private id;

private name;

//getter and setter....
}


It doesn't work with org.hibernate.exception.SQLGrammarException near (C.id).

Any solution for this? I wonder if the method in viewtopic.php?f=1&t=943217&hilit=dynamic+dynamic+instantiation is the only solution. I don't want to use the xml since I have used annotation in all of my code.


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

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.