When I toggle between Text and Designer view of an Entity with Transient attributes, the @Transient annotation keeps being removed from all of them. I have to remember to keep putting it back…
Could you show the code of the entity class header and a couple of attributes where the annotation is removed by Studio?
Sure thing -
package com.medflex.medflexj.entity.invoice;
(imports, lots of)
@NamePattern("%s (%s)|number,phase")
@Table(name = "MEDFLEXJ_INVOICE", indexes = {
@Index(name = "IDX_MEDFLEXJ_INVOICE_ON_PATIENT_ID_NUMBER_", columnList = "PATIENT_ID, NUMBER_"),
@Index(name = "IDX_MEDFLEXJ_INVOICE_ON_GUARANTOR_ID_NUMBER_", columnList = "GUARANTOR_ID, NUMBER_")
})
@Entity(name = "medflexj_Invoice")
public class Invoice extends StandardEntity {
private static final long serialVersionUID = 4088782201429254801L;
Transient 1:
@Transient
@MetaProperty(related = "lines")
public BigDecimal getBaseTotalAmount() {
(code...)
}
Transient 2:
@Transient
@MetaProperty(related = "lines")
public BigDecimal getTotalWriteOff() {
(code...)
}
@Transient
annotation is not needed on methods that are used as read-only properties, they are not recognized by JPA anyway.
So you can safely accept the removal by Studio.
Odd. Studio put it there in the first place.
What is the @Transient
annotation for, then?
Right, Studio did this before, it was a mistake.
@Transient
is needed only for fields that you don’t want to store, but JPA would try map them to a column by default.