Generated EntityViewImpl constructor will throw NPE for additional @Mapping collection fields
See original GitHub issueDescription
Generated CatWithKittenViewImpl
constructor will throw NullPointerExceptions
for additional @Mapping
collection fields. See the following scenario:
public interface CatWithKittenView extends CatIdView {
@Mapping("kittens[gender=com.example.Gender.MALE].owner")
Collection<PersonIdView> getMaleKittenOwners();
}
The generated CatWithKittenViewImpl
constructor:
public CatWithKittenViewImpl( Long id) {
this.$$_kind = (byte) 1;
this.maleKittenOweners = (Collection<PersonIdView>) (java.util.Collection<?>) CatWithKittenView_.maleKittenOwners.attr().getCollectionInstantiator().createCollection(0);
this.id = id;
}
In this case CatWithKittenView_.maleKittenOwners
will throw the NPE since there is no maleKittenOwners
field mapped in the enitiy.
Environment
Version: 1.6.0 JPA-Provider: 5.4 DBMS: MariaDB Application Server: Tomcat (Spring Boot)
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Blazebit - Bountysource
Generated CatWithKittenViewImpl constructor will throw NullPointerExceptions for additional @Mapping collection fields. See the following scenario:
Read more >java - What is a NullPointerException, and how do I fix it?
Applications should throw instances of this class to indicate other illegal uses of the null object. It is also the case that if...
Read more >Builder set methods null friendly · Issue #1451 - GitHub
When we are mapping a class to another, usually we end up with something like this: ... Builder will thrown a NullPointerException ....
Read more >How to deal with NullPointerException in Java with Examples
NullPointerException has outlined scenario when it could occur: 1) When you call the instance method on a null object. you won't get a...
Read more >Java NullPointerException - Detect, Fix, and Best Practices
When we run the above program, it throws the following NullPointerException error message. Exception in thread "main" java.lang.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you please confirm if enabling the scanning resolves your issue?
Thanks for confirming!