В базе данных есть таблица (Firebird), она сопоставлена с Entity.
Хранимая процедура работает с этой таблицей, которая возвращает как значения полей из таблицы, так и вычисленное значение.
Для этого вычисленного значения в Entity я создал переменную Transient.
У меня есть SqlResultSetMapping, в котором я записал соответствие полей из хранимой процедуры полям в Entity.
Проблема в том, что в поле Transient ничего не записано.
Возможно ли установить вычисленное значение в поле Transient?
@NamedStoredProcedureQuery(
name = Building.VR,
procedureName = "VALUATION_RESULTS_VC",
resultSetMappings = "Mapping",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "IP_ID", type = Integer.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "P_ID", type = Integer.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "P_CLASS", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "P_CRN_VC", type = Double.class)
}
)
@SqlResultSetMapping(
name = "Mapping",
entities = @EntityResult(
entityClass = Building.class,
fields = {
@FieldResult(name = "id", column = "P_ID"),
@FieldResult(name = "name", column = "P_CLASS"),
@FieldResult(name = "crn", column = "P_CRN_VC")
}
)
)
@Access(AccessType.FIELD)
@Entity
@Table(name = "main_tab")
public class Building extends BaseEntity {
public static final String VR = "Asset.VR";
@Transient <-if you remove Transient and create such a real field in the table, then everything works. But this field is calculated and it is not needed in the table.
private Double crn;
public Double getCrn() {
return crn;
}
public void setCrn(Double crn) {
this.crn = crn;
}
}
@MappedSuperclass
public abstract class BaseEntity {
@Id
@Column(name = "id")
private Integer id;
@Column(name = "name")
private String name;
public Integer getId() {
return id;
}
public String getName() {
return name;
}
}