You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our Sonar analysis available here shows we often have the same "bug", which is Make this value-based field transient so it is not included in the serialization of this class.
To have an explanation on why value-based fields must not be transient have a look here. In fact, this isn't a bug "yet", it just might be in the future.
Now this is in fact a real problem:
Our JPA entities need to be Serializable as it's part of the JPA spec, and as it's very likely people will put them in a cache (which can be distributed, or off heap)
We obviously have dates in those entities, and classes from java.time are marked as value-based
The solution proposed by Sonar, which is to make those fields transient, is not possible: those fields should not be transient, they should be saved in a database, and they should be available in a cache... You just don't resolve a problem by deleting it!
So I'm wondering what's the best solution is!
The text was updated successfully, but these errors were encountered:
This really looks like one those Sonar rules that shouldn't be there in the first place. It's probably OK in plain Java code, but when using Hibernate this just makes no sense to have the field transient.
We could maybe have a page for configuring Sonar in which we explain why this rule (and probably others. eg if we choose to keep field injection) must be deactivated ?
@rzauel thanks for giving the solution. I was worried about this issue, but in my case I don't actually need to Serialize the objects, since I'm using SpringData instead of JPA.
Our Sonar analysis available here shows we often have the same "bug", which is
Make this value-based field transient so it is not included in the serialization of this class
.To have an explanation on why value-based fields must not be transient have a look here. In fact, this isn't a bug "yet", it just might be in the future.
Now this is in fact a real problem:
Serializable
as it's part of the JPA spec, and as it's very likely people will put them in a cache (which can be distributed, or off heap)java.time
are marked as value-basedtransient
, is not possible: those fields should not betransient
, they should be saved in a database, and they should be available in a cache... You just don't resolve a problem by deleting it!So I'm wondering what's the best solution is!
The text was updated successfully, but these errors were encountered: