-->
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.  [ 6 posts ] 
Author Message
 Post subject: Query with constant value
PostPosted: Thu Nov 24, 2005 1:10 pm 
Newbie

Joined: Thu Nov 24, 2005 12:48 pm
Posts: 3
Location: Orlandia/SP/Brasil
HI!

My name is Arthur. I'm a Brazilian developer. (Sorry, my English is bad...)

I can't execute the following query:

Code:
select f.id, "constant" from TableVO f


The "constant" field is a string value. I also tried to execute this:
Code:
select f.id, new String("constant") from TableVO f


the error: class not found: String

So

Code:
select f.id, new java.lang.String("constant") from TableVO f


the error: undefined alias: "constant"



What's wrong?

Could anybody help me?

Thanks in advance

_________________
Arthur Cesar Oreana.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:23 pm 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
your query string is not correct HQL.

please read http://www.hibernate.org/hib_docs/refer ... /#queryhql

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:36 pm 
Newbie

Joined: Mon Sep 19, 2005 4:30 am
Posts: 11
you can add whatever constant you want in the loop processing the query result.

you could use single quots for
SQL literals 'foo', 69, '1970-01-01 10:00:01.0'

you could also use a variable :var and afterwards set the String


Top
 Profile  
 
 Post subject: Query with constant value
PostPosted: Thu Nov 24, 2005 1:40 pm 
Newbie

Joined: Thu Nov 24, 2005 12:48 pm
Posts: 3
Location: Orlandia/SP/Brasil
axismundi wrote:
your query string is not correct HQL.

please read http://www.hibernate.org/hib_docs/refer ... /#queryhql


Why my query is not correct HQL?

_________________
Arthur Cesar Oreana.


Top
 Profile  
 
 Post subject: Re: Query with constant value
PostPosted: Thu Nov 24, 2005 1:47 pm 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
aoreana wrote:
axismundi wrote:
your query string is not correct HQL.

please read http://www.hibernate.org/hib_docs/refer ... /#queryhql


Why my query is not correct HQL?


could you explain what exactly you want to query?
perhaps write your statement as SQL?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject: Re: Query with constant value
PostPosted: Thu Nov 24, 2005 2:03 pm 
Newbie

Joined: Thu Nov 24, 2005 12:48 pm
Posts: 3
Location: Orlandia/SP/Brasil
axismundi wrote:
aoreana wrote:
axismundi wrote:
your query string is not correct HQL.

please read http://www.hibernate.org/hib_docs/refer ... /#queryhql


Why my query is not correct HQL?


could you explain what exactly you want to query?
perhaps write your statement as SQL?


The query:

Code:
SELECT id, description, "constant here" FROM table;


and the resuilt:

id | description |
---|---------------|---------------------
1 | mouse | constant here
2 | keyboard | constant here

_________________
Arthur Cesar Oreana.


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