How can I write the sql query select sum(amount * direction) from transactions into hibernate criteria ?
I think what you need is formula. Something like this,
@Entity
@Table('TRANSACTIONS')
Class transactions {
@Column("AMOUNT")
private double amount;
@Column("DIRECTION")
private double direction;
@Formula("AMOUNT * DIRECTION")
private double multiplication;
}
And add multiplication column to your projection list.