Amongst all the past and future posts in this series, this is definitely my favorite. This is ignorance at its limits. I really mean it. For those of you who are unfamiliar with the Transient annotation in Java Persistence API let me quote from the official Java document: "This annotation specifies that the property or field is not persistent. It is used to annotate a property or field of an entity class, mapped superclass, or embeddable class."
What does it mean? When you annotate a class with the @Entity annotation, by convention the properties get mapped to a column with the same name as property's name. In some cases entities have some properties which are for runtime use only and should not be persisted. For example a boolean property holding the selected status of the object in UI tables. To exclude these properties from being persisted, you must annotate them with @Transient. You have two options: annotating fields or getters. I personally prefer field annotations, because it makes my code more readable.
Let's see what our friend has done here:
This helper method belongs to a controller. Annotating a helper static method on a controller with @Transient is something I have never seen before!
هیچ نظری موجود نیست:
ارسال یک نظر