How to persist LocalDate with JPA?

With JPA 2.2, you no longer need to use converter it added support for the mapping of the following java.time types: java.time.LocalDate java.time.LocalTime java.time.LocalDateTime java.time.OffsetTime java.time.OffsetDateTime @Column(columnDefinition = “DATE”) private LocalDate date; @Column(columnDefinition = “TIMESTAMP”) private LocalDateTime dateTime; @Column(columnDefinition = “TIME”) private LocalTime localTime;

Is it possible for class to inherit the annotations of the super class

Yes it is possible if the annotation has @Inherited added to it. For example, the @Transactional annotation has @Inherited. From the docs: Indicates that an annotation type is automatically inherited. If an Inherited meta-annotation is present on an annotation type declaration, and the user queries the annotation type on a class declaration, and the class … Read more

Spring Redis – Read configuration from application.properties file

You can use @PropertySource to read options from application.properties or other property file you want. Please look PropertySource usage example and working example of usage spring-redis-cache. Or look at this small sample: @Configuration @PropertySource(“application.properties”) public class SpringSessionRedisConfiguration { @Value(“${redis.hostname}”) private String redisHostName; @Value(“${redis.port}”) private int redisPort; @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); … Read more

How to reuse the same connection with a Spring’s JdbcTemplate?

Spring provides a special DataSource that allows you to do this: SingleConnectionDataSource Changing your code to this should do the trick: SingleConnectionDataSource dataSource = new SingleConnectionDataSource(); …. // The rest stays as is For use in multi-threaded applications, you can make the code re-entrant by borrowing a new connection from the pool and wrapping it … Read more

No WebApplicationContext found: no ContextLoaderListener registered?

You’ll have to have a ContextLoaderListener in your web.xml – It loads your configuration files. <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> You need to understand the difference between Web application context and root application context . In the web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)