我想在同一实体中添加两个数字。这是正确的还是如何做到的?
@Data
@Entity
public class Product {
@Id
private Integer productId;
private String productName;
private Integer noOfUnits;
private Double cartonPrice;
@Transient
private Double unitPrice=cartonPrice-noOfUnits;
}
答案 0 :(得分:0)
不,这不是正确的处理方法!您应该根据需要在哪个控制器中计算出unitPrice字段并将其保存在数据库中,在服务类中进行所有这些操作。
答案 1 :(得分:0)
SELECT eps.PROPOSAL_NUMBER, eps.TITLE, per.FULL_NAME, ext.NRP_IREF_CD, ext.RESEARCH_TYPE_CD,
nsf.NSF_CODE, ext.NPS_THRUST_DESCRIPTION,
CASE
WHEN OPTION_1 = 'Y' THEN 'Option 1'
WHEN OPTION_2 = 'Y' THEN 'Option 2'
WHEN OPTION_3 = 'Y' THEN 'Option 3'
WHEN OPTION_4 = 'Y' THEN 'Option 4'
WHEN OPTION_5 = 'Y' THEN 'Option 5'
WHEN OPTION_6 = 'Y' THEN 'Option 6'
WHEN OPTION_7 = 'Y' THEN 'Option 7'
WHEN OPTION_8 = 'Y' THEN 'Option 8'
WHEN OPTION_9 = 'Y' THEN 'Option 9'
WHEN OPTION_0 = 'Y' THEN 'Not Applicable'
ELSE ''
END ONR,
abs.ABSTRACT_DETAILS,
k.keywords
FROM EPS_PROPOSAL eps
LEFT JOIN EPS_PROPOSAL_EXT_T ext
ON eps.PROPOSAL_NUMBER = ext.PROPOSAL_NUMBER
LEFT JOIN EPS_PROP_PERSON per
ON eps.PROPOSAL_NUMBER = per.PROPOSAL_NUMBER AND
(per.PROP_PERSON_ROLE_ID = 'PI' OR per.PROP_PERSON_ROLE_ID = 'PD')
LEFT JOIN EPS_PROP_ABSTRACT abs
ON eps.PROPOSAL_NUMBER = abs.PROPOSAL_NUMBER
LEFT JOIN NSF_CODES nsf
ON eps.NSF_CODE = nsf.NSF_SEQUENCE_NUMBER
OUTER APPLY(
SELECT
LISTAGG(sk.DESCRIPTION, ', ') WITHIN GROUP (ORDER BY sk.DESCRIPTION) AS KEYWORDS
FROM EPS_PROP_SCIENCE_KEYWORD key
LEFT JOIN SCIENCE_KEYWORD sk
ON key.SCIENCE_KEYWORD_CODE = sk.SCIENCE_KEYWORD_CODE
WHERE eps.PROPOSAL_NUMBER = key.PROPOSAL_NUMBER
) k
WHERE eps.OWNED_BY_UNIT = '401' AND eps.requested_start_date_initial >= DATE '2019-10-01';
使用此功能可以进行此计算。