[java] Java Persistence API (JPA) Entity Rule: Public or Protected No-Arg Constructor
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.5k
- Forks
- 1.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 54
Description
Proposed Rule Name: JPANoArgumentConstructor
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 a no-argument constructor. The constructor must have public or protected access.
Code Sample:
The following class will cause a problem at runtime because it does not have a no-argument constructor.
@Entity
class MyEntity
{
public MyEntity(int value)
{
...
}
}
The following class is correct.
@Entity
class MyEntity
{
protected MyEntity()
{
...
}
public MyEntity(int value)
{
...
}
}
Possible Properties:
- allowPackage: Hibernate allows for package protected no-argument constructors
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files, tests, or entry points are named. Start by locating the Java rule implementation and test conventions for annotation-based rules, then verify the behavior against the two constructor examples and the optional package-private setting described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100