-->
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: Hibernate 2.2?
PostPosted: Fri Jul 09, 2004 6:21 am 
Beginner
Beginner

Joined: Mon May 17, 2004 7:15 am
Posts: 24
Hi,

Does anybody know how to use the HSQL in a property formula, like:
Quote:

<property
name="amount"
type="int"
formula="(select count(*) from domain.TreeNode)"/>

I searched topics in the forum and a guy saild that function would be supported in Hibernate 2.2. Is it realy? And when will Hibernate 2.2 or 3 will be released?


Thanks in advance.

James


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 09, 2004 6:22 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is already supported in Hibernate 2.1, just use it. However, it's a SQL expression, not an HQL expression.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 09, 2004 10:47 am 
Beginner
Beginner

Joined: Mon May 17, 2004 7:15 am
Posts: 24
christian wrote:
This is already supported in Hibernate 2.1, just use it. However, it's a SQL expression, not an HQL expression.


A problem with a SQL expression is that wrong SQL statements will be generated from the same mapping file used in the different schemas. It is better that all possible query statements in the model are written in the same language, either SQL or HQL. Do you think so?

Regards,

James


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 09, 2004 10:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I think that queries should be externalized to the mapping files, hence I don't see a problem with either language or "wrong SQL".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 10, 2004 9:52 pm 
Beginner
Beginner

Joined: Mon May 17, 2004 7:15 am
Posts: 24
christian wrote:
I think that queries should be externalized to the mapping files, hence I don't see a problem with either language or "wrong SQL".


I do agree. But what I was suggesting to consider is that using HQL in a formula property will keep the model more flexible and programmers do not need to know stuff, e.g the real schema, table name or column name, in the depoyment process, but just use HQL in the formula. In my opition, it is a good engineering practice not to use two classes of query statements together in the same model.

Just a personal point and welcome any discussion.

Regards,

James


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 10, 2004 9:54 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
But you are looking at the database schema anyway when you write the mapping, so writing a SQL expression is perfectly fine. Keep in mind that you sometimes _need_ native SQL to get what you want in the formula. This is much more powerful than using HQL, which has a higher abstraction level.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.