2023-04-06

Spring Boot @Scheduled only run 1 thread.

 

Else use fixedRate


Reference URL: https://stackoverflow.com/a/35094357/6462295

But I'm not sure will it queue up the Spring schedule...( yet to get a way to verify... :-\ )

But tested, definitely 


Implementation with @Scheduled with cron

Reference URL: https://stackoverflow.com/a/74900033/6462295

java.util.concurrent.locks.ReentrantLock




https://stackoverflow.com/a/74900033/6462295









[Solved] - object to JSON string exception


Relevant tags:
  1. Spring Boot 2.7.6
  2. JUnit 5
  3. JPA
 

Error Message:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.yourcompany.entity.Table$HibernateProxy$3enmhWuU["hibernateLazyInitializer"])


Reference URL: https://stackoverflow.com/a/67354659/6462295

Adding annotation below to your entity.

@com.fasterxml.jackson.annotation.JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
















[Solved] - LazyInitializationException: could not initialize proxy

 


org.hibernate.LazyInitializationException: could not initialize proxy [com.yourcompany.entity.Table#123456] - no Session


relevant tags:
  1. Spring Boot 2.7.6
  2. JUnit 5
  3. JPA

Resolved by both below:

1. Adding annotation below to your test function:
Reference URL: https://stackoverflow.com/a/72863346/6462295
@org.springframework.transaction.annotation.Transactional(readOnly = true)





2. Adding configuration into application.properties
Reference URL: https://stackoverflow.com/a/38690930/6462295

spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true






Google Referrals