Crjvm205 - #122
Conversation
Create ForceLazyFetchTypeUse.java
Crjvm205 sls
… into CRJVM205-WKR
Crjvm205 wkr
… into CRJVM205-WKR
Crjvm205 wkr
|
Hi @dirdr, |
|
This PR has been automatically marked as stale because it has no activity for 30 days. |
|
Hi @dirdr, |
|
This PR has been automatically marked as stale because it has no activity for 30 days. |
| * OneToOne: Eager | ||
| * reporting the issues if necessary | ||
| */ | ||
| private void performsCheck(Arguments arguments, AnnotationTree annotationTree, Tree tree) { |
There was a problem hiding this comment.
here, no need to give arguments as input parameter because it already is present inside annotationTree input parameter
|
|
||
| import java.util.List; | ||
|
|
||
| @Rule(key = "EC80", name = "Developpement", |
There was a problem hiding this comment.
there is a new way to declare configuration of one rule : please see other rules as example
| @@ -0,0 +1,16 @@ | |||
| { | |||
| "title": "Force the use of FetchType LAZY on collections in Entity JPA", | |||
There was a problem hiding this comment.
now, it isn't the good way to declare rule properties but inside ecocode-rules-specifications (please see another rule as example)
|
|
||
| @Column(name = "ORDER", length = 50, nullable = false, unique = false) | ||
| private Set<OrderItem> items = new HashSet<OrderItem>(); | ||
|
|
There was a problem hiding this comment.
please as a new use case with default value for fetch keywork (thus, without "fetch" variable assigned)
| import javax.persistence.Temporal; | ||
| import javax.persistence.TemporalType; | ||
| import javax.persistence.Transient; | ||
|
|
There was a problem hiding this comment.
why don't you give all use cases in a single file ? why several test files ?
| registrar.register(context); | ||
|
|
||
| assertThat(context.checkClasses()).hasSize(19); | ||
| assertThat(context.checkClasses()).hasSize(20); |
There was a problem hiding this comment.
maybe value has to be changed. to recheck locally, please
|
PR on java-test-project : https://github.com/green-code-initiative/ecoCode-java-test-project/pull/5 |
|
to discuss in core-team :
but I think we can't force developers not to use EAGER key word if they really need it. do we refuse this rule or not ? |
|
Hello, we do not force the user to not use "EAGER", it is just a code smell. He can always ignore it. The true question is, when we use JPA entities, is the "EAGER" keyword a classic use? If in 90% of the case its use is justified may be we should not raise the code smell to avoid to pollute the analysis. |
|
This PR has been automatically marked as stale because it has no activity for 60 days. |
|
Hi @AntoineMeheut, @dirdr , @jhertout several PR have worked on this same subject (FetchType Lazy instead of Eager for OneToMany et ManyToMany relations). After worked on a complete analysis to check if this rule is relevant :
Thus I created a new PR to :
Here is the PR : #487 Sorry, but I have to close this PR. |
CRJVM205 - Force the use of FetchType LAZY on collections in Entity JPA
Pitch : Consider using LAZY mode on your FetchType for collections in JPA type entities. This will reduce the amount of data loaded into memory. And having less data loaded into memory reduces power consumption. Any electricity not produced is good for our planet.