-->
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: can I refer to class constants in a query?
PostPosted: Thu Dec 09, 2004 6:36 pm 
Newbie

Joined: Tue Jul 27, 2004 1:17 pm
Posts: 12
Is there a way to use a class constant in a query?
My query wants to check a field's value against one or more values and I'd rather use symbolic constants for the values. Thank you.

Hibernate version:2.1

Mapping documents:

/**
* @hibernate.query name="foo"
* query="from FooDTO foo where field = FooDTO.MYCONSTANT)
*/
public class FooDTO {
public static final int MYCONSTANT = 42;
private int field;

/**
* @hibernate.property
*/
public int getField() {
return field;
}
public void setField(int newField) {
field = newField;
}
}

The generated SQL (show_sql=true):
SQL Error: 904, SQLState: 42000
FooDTO.MYCONSTANT: invalid indentifier


[


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 6:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Not possible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well - a "workaround" could be to add them to hibernate.query.substitutions in the hibernate.properties

(but it feels "dirty")

_________________
Max
Don't forget to rate


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.