Uploaded image for project: 'Spring Data Couchbase'
  1. Spring Data Couchbase
  2. DATACOUCH-626

all-arguments constructor incompatible with '@Version private long version'

    XMLWordPrintable

    Details

      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;
        }
      
      

        Attachments

          Activity

            People

            Assignee:
            mikereiche Michael Reiche
            Reporter:
            jpringle jpringle
            Last updater:
            Spring Issues Spring Issues
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: