You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hibernate @Enity annotation changes Jackson serialization behavior #2267
It appears to be PersistentEntityJackson2Module from spring-data-rest that is causing this behavior. The updateBuilder method is called which removes ID attributes.
@olivergierke it looks like this is expected behavior, do we need to provide a quick global opt-out property.
@efenderbosch Are you actually using Spring Data Rest? If not you could try removing it from your classpath. You can also exclude RepositoryRestMvcAutoConfiguration as a work-around.
I'm using Spring Data Rest because it brings in spring-web (HttpStatus) and spring-hateos (PagedResources). Our app is a pretty basic RESTful service w/ JPA.
If there's a different spring-boot-starter or combination that will provide this functionality, I can use that instead.
I'd like to make RepositoryRestMvcBootConfiguration's RepositoryRestConfiguration bean @ConditionalOnMissingBean, however Spring Framework won't let me. It evaluates the condition on the overriding method and determines that it should be skipped, but then looks at the unconditional overridden method on the superclass and creates the bean anyway. I've opened SPR-12695.
My comment above was with a view towards users declaring their own RepositoryRestConfiguration bean as @efenderbosch has attempted above. A major drawback of this approach is that the bean has to be called config as Spring Data REST references it by name.
RepositoryRestMvcBootConfiguration was recently made public (#2392). This provides a much nicer way to customise RepositoryRestConfiguration. For example, here's how to enable the exposure of ids for an entity:
This allows you to use Spring Data REST's approach to customising the configuration while also taking advantage of Boot's auto-configuration – any spring.data.rest.* properties will still be applied to the RepositoryRestConfiguration instance.
@efenderbosch If you're not actually using Spring Data REST, but simply looking for a starter to pull in spring-web and spring-hateoas, we added spring-boot-starter-hateoas recently (#2396). It'll be in 1.2.2.
Activity
philwebb commentedon Jan 1, 2015
It appears to be
PersistentEntityJackson2Modulefrom spring-data-rest that is causing this behavior. TheupdateBuildermethod is called which removes ID attributes.@olivergierke it looks like this is expected behavior, do we need to provide a quick global opt-out property.
@efenderbosch Are you actually using Spring Data Rest? If not you could try removing it from your classpath. You can also exclude
RepositoryRestMvcAutoConfigurationas a work-around.philwebb commentedon Jan 1, 2015
BTW also tested with 1.1.10 so this isn't a recent regression.
efenderbosch commentedon Jan 1, 2015
I'm using Spring Data Rest because it brings in spring-web (HttpStatus) and spring-hateos (PagedResources). Our app is a pretty basic RESTful service w/ JPA.
If there's a different spring-boot-starter or combination that will provide this functionality, I can use that instead.
efenderbosch commentedon Jan 1, 2015
I was hopeful that this would work, but it didn't:
I'm not confident that my bean is replacing the default bean. If I leave off
@Primarythen I get "expected single matching bean but found 2."efenderbosch commentedon Jan 1, 2015
This does work, however:
wilkinsona commentedon Feb 5, 2015
I'd like to make
RepositoryRestMvcBootConfiguration'sRepositoryRestConfigurationbean@ConditionalOnMissingBean, however Spring Framework won't let me. It evaluates the condition on the overriding method and determines that it should be skipped, but then looks at the unconditional overridden method on the superclass and creates the bean anyway. I've opened SPR-12695.wilkinsona commentedon Feb 12, 2015
My comment above was with a view towards users declaring their own
RepositoryRestConfigurationbean as @efenderbosch has attempted above. A major drawback of this approach is that the bean has to be calledconfigas Spring Data REST references it by name.RepositoryRestMvcBootConfigurationwas recently made public (#2392). This provides a much nicer way to customiseRepositoryRestConfiguration. For example, here's how to enable the exposure of ids for an entity:This allows you to use Spring Data REST's approach to customising the configuration while also taking advantage of Boot's auto-configuration – any
spring.data.rest.*properties will still be applied to theRepositoryRestConfigurationinstance.wilkinsona commentedon Feb 12, 2015
@efenderbosch If you're not actually using Spring Data REST, but simply looking for a starter to pull in spring-web and spring-hateoas, we added
spring-boot-starter-hateoasrecently (#2396). It'll be in 1.2.2.new23d commentedon Sep 26, 2015
Note that
RepositoryRestMvcBootConfigurationhas since been renamed toSpringBootRepositoryRestMvcConfiguration.