-->
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.  [ 5 posts ] 
Author Message
 Post subject: queries and compilation
PostPosted: Mon Jan 26, 2004 9:45 am 
Newbie

Joined: Wed Jan 21, 2004 10:09 am
Posts: 13
Hi all,

I've recently started using Hibernate, and have been loving it. It just helps so much!

One problem that I have had with it is the queries - the queries are strings, which don't get compiled. It would be nice to be able to have the queries compiled to have them checked for validaty. In particular, I would like to be able to change an objects attribute name, and have the problem highlight for me.

For example, I might have a query:

"from object as o where o.name = ?"

If the attribute 'name' changes in o, the query, because its a string, won't throw a compile exception, and I won't know that there is a problem until runtime. Is there a way around this?

Thanks for any suggestions,

Mark

PS. Named SQL queries and the criteria approach are not solutions. Named sql queries do not get compiled at compile time, and neither does the criteria approach.

ie.
List cats = sess.createCriteria(Cat.class)
.add( Expression.like("name", "Fritz%") )
.add( Expression.between("weight", minWeight, maxWeight) )
.list();

The "name" is still being added as a string, which is the problem


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 9:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Quote:
Is there a way around this?


No, not yet. Hasn't this been discussed here allready some days ago?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 11:21 am 
Newbie

Joined: Wed Jan 21, 2004 10:09 am
Posts: 13
Hi All,

Terribly sorry if I've brought up a topic that was already discussed. I did take a look around before I posted, but probably missed the obvious. Would you be so kind as to point me in the right direction, or with a link to the earlier discussion so I can educate myself?

Thank you for pointing out that this isn't possible right now. That helps. I've thought about it for a bit, and it seems to me like a difficult problem, but it would be a nice one to solve.

Best regards,

Mark


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 11:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well, it was in a thread started by you http://forum.hibernate.org/viewtopic.php?t=927253&highlight=query+compile Simply crossposting the same stuff again is not especially productive.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 11:29 am 
Newbie

Joined: Wed Jan 21, 2004 10:09 am
Posts: 13
I cross-posted because I thought I would try the beginners forum first, in case this was a dumb/simple question. Apparently it wasn't and no one there could give me a difinitive answer either, so I thought I would try here.

This approach seems appropriate to me, but let me know if you think otherwise and what else I could have done instead.

Thanks,

Mark


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