question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

initShim breaks Spring Data JDBC

See original GitHub issue

Spring folks ignore the transient keyword by design. As a result Spring tries to persist the field and fails.

I tried (without success) adding @Transient to it like this

@InjectTransient
@Nullable
protected abstract Object initShim();


@InjectAnnotation(type = Transient.class, target = FIELD)
@Target(METHOD)
@interface InjectTransient {}

Would be nice to have a solution/workaround

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
aurambajcommented, Dec 27, 2020

I have a similar issue while working with Spring jdbc. Got a working solution relying on unsafeDefaultAndDerived = true. @elucash Is that going to be an issue moving forward since it is the older way of doing things?

(no luck with SYNTHETIC_FIELDS but I may have missed something)

@Immutable
@Value.Style(
    unsafeDefaultAndDerived = true,
    builtinContainerAttributes = false,
    typeImmutable = "*",
    of="new"
)
@InjectPersistenceConstructor
public abstract class AbstractOrganization implements Persistable<UUID> {

  @Value.Parameter
  @Id
  @Default
  public UUID getId() {
    return UUID.randomUUID();
  }

  @Value.Parameter
  @Default
  public Instant getCreatedAt() {
    return Instant.now();
  }

  @Value.Parameter
  public abstract String getName();

  /** for spring jdbc to control new instances if using manually set ids */
  @InjectTransient
  @Default
  @Override
  public boolean isNew() {
    return true;
  }
}
0reactions
elucashcommented, Dec 28, 2020

by disabling builtin container handling, Immutables doesnt not consider array as an array but as regular reference type (as anything extending Object) and calls Object.equals. You’ve probably disabled containers to fight something in a way containers work by default, so some other solution may be needed, dunno if this can be solved by jdkOnly or beanFriendlyModifiables. In general, if not for the peculiarities of serialization mechanisms, I would wrap any raw array into either collection or specialized type (ByteString / MyBlob / Data) just for the purpose of controlling toString, equivalence and [de-]serialization (how hard it can be to override some serializers/adapters? well for some technologies this definitely a PITA)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Data JDBC - Reference Documentation
The Spring Data JDBC project applies core Spring concepts to the development of solutions that use JDBC databases aligned with Domain-driven ...
Read more >
Spring data jdbc seems not working with final attributes
I'm trying spring data JDBC (1.1.0.M3). I have a Formateur (Teacher) class which contains an email attribute (class Email).
Read more >
Spring Data JPA to Spring Data JDBC – a smooth ride?
Spring Data JPA and Spring Data JDBC use Spring Data Commons as a base library. Both share the same abstractions; the most important...
Read more >
spring-projects/spring-data - Gitter
Hi Team, I am using spring data ignite library and having configuration done ... the subsequent resized images for UI efficiency with JDBC...
Read more >
Is there a reason to not use Spring Data JPA and Jackson in ...
I'm hoping that Spring Data JDBC will get query method derivation ... know to stay away from fringe parts that break between upgrades....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found