Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Complete
-
Affects Version/s: None
-
Fix Version/s: 4.1 GA (2020.0.0), 4.0.5 (Neumann SR5)
-
Component/s: None
-
Labels:None
-
Pull Request URL:
Description
When attempting to use an all-arguments constructor as the persistence constructor in conjunction with a @Version property, if the type of the version property is a native type then object instantiation will fail.
Queries and key-value gets fail to construct entities due to an attempt to pass "null" as the version parameter in the all-arguments constructor.
The following simple document class will fail to load with the following exception:
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate SubscriptionToken using constructor public SubscriptionToken(java.lang.String,long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,long) with arguments 19df69a7-db2f-4cc0-94f9-d2a15624b5fc,null,SafetyAll,SafetySuper1,appId unknown,deviceId unknown,1601974697119
@Getter @ToString @EqualsAndHashCode @Document public class SubscriptionToken { private @Id @GeneratedValue(strategy = GenerationStrategy.UNIQUE) String id; private @Version long version; private @Field String subscriptionType; private @Field String userName; private @Field String appId; private @Field String deviceId; private @Field long subscriptionDate; public SubscriptionToken( String id, long version, String subscriptionType, String userName, String appId, String deviceId, long subscriptionDate) { this.id = id; this.version = version; this.subscriptionType = subscriptionType; this.userName = userName; this.appId = appId; this.deviceId = deviceId; this.subscriptionDate = subscriptionDate; }