-->
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: @Formula and custom functions
PostPosted: Tue Jun 03, 2008 9:55 am 
Newbie

Joined: Tue May 30, 2006 9:45 am
Posts: 5
Hi!

Here is my problem: I have a bean, lets say User, where I'd like to map one property to a custom function:

Code:
@Entity
public class User {
   private int count;

   @Formula("rowcount")
   public int getCount() {return count;}
   public void setCount(int count){this.count=count};
}

and then create two custom dialecs - one for Oracle and one for HSQL:

Code:
public static class CustomOracle10gDialect extends Oracle10gDialect {
   public CustomOracle10gDialect() {
      registerFunction("rowcount", new NoArgSQLFunction("count(*) over", Hibernate.INTEGER, true));
   }
}

public static class CustomHSQLDialect extends HSQLDialect {
   public CustomHSQLDialect() {
      registerFunction("rowcount", new NoArgSQLFunction("1", Hibernate.INTEGER, false)); // don't really care about the output
   }
}

because I need to use the same bean in the production code and in test units, and there is no "count(*) over()" function in HSQL..

Is that makes any sense? And is that possible somehow?

Thanks!


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.