Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-2026

Final id field causes UnsupportedOperationException when reading object.

    Details

      Description

      Having the @Id field declared final caues UnsupportedOperationException.

      static class ItemContainer {
      
      	@Id final String id;
      
      	@PersistenceConstructor
      	ItemContainer(String id) {
      		this.id = id;
      	}
      }
      
      java.lang.UnsupportedOperationException: No accessor to set property @org.springframework.data.annotation.Id()final java.lang.String org.springframework.data.mongodb.core.mapping.MappingTests$ItemContainer.id!
      	at org.springframework.data.mongodb.core.mapping.MappingTests$ItemContainer_Accessor_m5ty4y.setProperty(Unknown Source)
      	at org.springframework.data.mapping.model.ConvertingPropertyAccessor.setProperty(ConvertingPropertyAccessor.java:60)
      	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:288)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cstrobl Christoph Strobl
                Reporter:
                cstrobl Christoph Strobl
                Last updater:
                Mark Paluch
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: