-->
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: SQL -> JPQL SUM and Distinct
PostPosted: Wed Oct 24, 2012 10:02 am 
Beginner
Beginner

Joined: Sat Feb 16, 2008 3:09 pm
Posts: 24
Hello we have to use JBoss 4.2.3 and its Hibernate version
unfortunately it appears that @NamedNativeQuery is not supported by this configuration.

I have to translate
Code:
SELECT SUM(ABR_RF_REST) FROM (SELECT  DISTINCT (abr_fall_id), ABR_RF_REST FROM tbe_abr WHERE ABR_RF_REST > 0)

to jpql
the objects is
Code:
@javax.persistence.Entity
@javax.persistence.Table( name="tbe_abr" )
public class ErgebnisRueckAbrechnung

  @javax.persistence.JoinColumn( name="abr_fall_id" )
  @Index(name="inx_abr_fall_id")
  private bla.dbaccess.domain.Fall fall = null;
 
  @javax.persistence.Column( name="abr_rf_rest", nullable=true )
  private java.lang.Double rueckforderungRest = null;



My problem is: I want a sum of all rueckforderungRest, but there may be multiple entries in the table tbe_adr with the same abr_fall_id and abr_rf_rest and I must add only one instance of these duplicates to the sum.

Thanks,

Hans


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.