У меня есть класс с именем голосования:
@Table(name = "PHY_VOTE")
public class VoteEntity extends BaseEntity<Long> implements Comparable {
public static final String TITLE = "title";
public static final String VALUE = "value";
public static final String USER = "user";
private String title;
private String value;
private UserEntity user;
public VoteEntity() {}
public VoteEntity(Long id) {
setId(id);
}
public VoteEntity(String title, String value, UserEntity user) {
this.title = title;
this.value = value;
this.user = user;
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "VOTE_ID")
@Override
public Long getId() {
return super.getId();
}
@FilterProperty(operation = FilterProperty.ILIKE)
@Column(name = "TITLE", nullable = false, length = 100)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@FilterProperty(operation = FilterProperty.ILIKE)
@Column(name = "VALUE", nullable = false, length = 4)
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@ManyToOne
@JoinColumn(name = "USER_ID", foreignKey = @ForeignKey(name = "PYH_VOTE_USER_FK"))
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
@Transient
@Override
public String getOptionsTitleProperty() {
return TITLE;
}
}
Как я могу создать следующую команду с критериями?
ВЫБРАТЬ t.TITLE, ROUND (SUM (t.VALUE) / COUNT(t.TITLE), 2) значение FROM PHY_VOTE t GROUP BY t.TITLE