Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Java Persistence API (JPA) Entity Rule: Non-final Instance Variables #2858

Open
numeralnathan opened this issue Oct 22, 2020 · 0 comments
Labels
a:new-rule Proposal to add a new built-in rule

Comments

@numeralnathan
Copy link

Proposed Rule Name: JPANonFinalInstanceVariables

Proposed Category: Bug

Description:

When a class is annotated with JPA's @Entity, there are certain requirements placed on the class. Please create a rule that requires the instance variables to be non-final.

Note: Hibernate allows for final instance variables but lazy-loading will not work.

Code Sample:

The following class will cause a problem at runtime because it has a final instance variable.

@Entity
class MyEntity
{
   private static final COUNT = 5;

   private final int m_data;
}

The following class is correct.

@Entity
class MyEntity
{
   private static final COUNT = 5;

   private int m_data;
}

Possible Properties:

Can you think of some properties?

@numeralnathan numeralnathan added the a:new-rule Proposal to add a new built-in rule label Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:new-rule Proposal to add a new built-in rule
Projects
None yet
Development

No branches or pull requests

1 participant