-->
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.  [ 2 posts ] 
Author Message
 Post subject: JPA / PostgreSQL9Dialect: registerFunction
PostPosted: Wed Feb 01, 2017 2:36 pm 
Newbie

Joined: Sat Sep 18, 2010 3:16 am
Posts: 5
Hallo zusammen,
ist es möglich, eine Nicht-Standard-SQL-Funktion von Postgresql wie "split_part" so zu registrieren, dass sie wie bspw. sum() funktioniert?

Folgendes Beispiel mit sum() kann ich in meiner javax.persistence.NamedQuery verwenden:
Code:
select v.property_1, sum(v.property_2) FROM entityname v GROUP BY v.property_1

Leider funktioniert es mit der split_part() Funktion nicht:
Code:
select v.property_1, split_part(v.property_3) FROM entityname v GROUP BY v.property_1

Folgende Exceptions werden geworfen:
- antlr.NoViableAltException: unexpected token: v
bzw.
- org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: v

Registriert habe ich die "split_part" wie folgt:
Code:
public class MyPostgreSQL9Dialect extends PostgreSQL9Dialect {    
   public MyPostgreSQL9Dialect () {
      super();
      registerFunction("split_part", new StandardSQLFunction("split_part", StandardBasicTypes.STRING));
   }
}

Zum besseren Verständnis habe ich die split_part - Funktion vereinfacht dargestellt.

Vielen Dank und Grüße
Jan


Top
 Profile  
 
 Post subject: Re: JPA / PostgreSQL9Dialect: registerFunction
PostPosted: Mon Feb 06, 2017 4:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
I don't think this thread is getting any attention. You should post to the English forum instead.


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