Friday, 8 January 2021

Java Chart Frameworks

JFree chart is the most recommended one.  


The major elements are involved as using JFree framework. 

ChartPanel: it is specific to the JFree; it is a container to hold the JFree charts, and it adapts to the SWING frame.   

XYPlot: it is the basic plotter, that draws an x-y diagram on the canvas. 

Axis: Date axis(X-axis) or Number axis(Y-axis) stands for Price or volume. 

Dataset: Candle dataset; or XY data set.


JFree candlestick chart, combined subplots. 

https://examples.javacodegeeks.com/desktop-java/jfreechart/jfree-candlestick-chart-example/


Creating a candlestick chart and line chart on a common chart

XYPlot plot = (XYPlot)chart.getPlot();
        XYDataset dataset2 = getDataset2(); //This is where you get your line data
        plot.setRenderer(1, new XYLineAndShapeRenderer(true, false));
        plot.setDataset(1, dataset2);


It is supposed to work with Java FX, via a Jfree-fx package. However,  I didn't make it work. The chart-viewer has a version error. 

Java FX candlestick chart

https://github.com/rterp/StockChartsFX


ChartFx is a scientific charting library developed at GSI for FAIR with focus on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points common in digital signal processing applications. Based on earlier Swing-based designs used at GSI and CERN, it is a re-write of JavaFX's default Chart implementation and aims to preserve the feature-rich and extensible functionality of earlier and other similar Swing-based libraries while addressing the performance bottlenecks and API issues. The motivation for the re-design has been presented at IPAC'19 (paperposter).


https://github.com/GSI-CS-CO/chart-fx


Java FX structure 

Application: have Stage(s); a Stage has a Scene; a Scene has a root Node, Node has children Nodes. 

TreeViewTable: combine tree view and table view together.

SplitPane: 

CombinedSubPlots

ChartViewer: Jfree-fx allows JFree Chart display on the Java FX 



How to integrate Java FX with SpringBoot


https://github.com/mvpjava/springboot-javafx-tutorial


Tutorial: Reactive Spring Boot Part 3 – A JavaFX Spring Boot Application

 








Turning off A package logging

 If you use Spring Boot, you may set to in the application.properties file. Example:

logging.level.org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer=OFF

Wednesday, 6 January 2021

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext':

Solution: 

rolling <groupId>com.h2database</groupId> back to lower version, <version>1.4.199</version>


 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-01-06 00:59:34.021 ERROR 17888 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nasdaqStocksRepository' defined in com.ynz.finance.pricetrend.domain.repository.NasdaqStocksRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1697) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1442) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:624) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:612) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.data.repository.config.DeferredRepositoryInitializationListener.onApplicationEvent(DeferredRepositoryInitializationListener.java:51) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.data.repository.config.DeferredRepositoryInitializationListener.onApplicationEvent(DeferredRepositoryInitializationListener.java:36) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at com.ynz.finance.pricetrend.DemoApplication.main(DemoApplication.java:25) [classes/:na]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]

at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]

at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.4.RELEASE.jar:2.3.4.RELEASE]

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

... 33 common frames omitted

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1224) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1255) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_201]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_201]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_201]

at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_201]

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

... 17 common frames omitted



Process finished with exit code 0





Sunday, 20 December 2020

Spring annotations


@Component is added at a class, meaning that this class will be scanned by the Spring container and loaded in the Spring context.  @Component is the most generic decoration. A @Service is a component; A @Controller is a component too. 

@Service means actually a specific @Component, which stands for a business logic layer.  So when a class is added with @Service, it will be scanned by Spring container and loaded in the context. 

@RestController  is also a specific @Component when a Spring context is initiated. These controllers will be instantiated and start waiting for the requests and making responses. 

@Autowired is specific to the Spring framework; it is equivalent to the Java @Injected 

@Configuration and its Relevant Annotations


@Configuration working with @Bean, @Value, @PropertySource, @ComponentScan and @Profile

@Configuration together with @Bean defines a bean blueprint, which tells a bean factory how to create a bean and its dependencies(DI).  In a simple word, it depicts a bean graph. 

@Configuration indicates a class, in which one or more @Beans methods are declared. 

What is a @Bean? @Bean is used to decorate a method. It tells Spring that this method is used to return an instantiated  @component or @Service. @Bean is used together with @Configuration class to tell Spring framework how to do DI. 



@Cofiguration working with externalized values

@Configuration class may need external env properties or other values defined in the other property files. 

Using  Environment API

Via Spring Environment injection, we may access properties. 
@Configuration
 public class AppConfig {

     @Autowired Environment env;

     @Bean
     public MyBean myBean() {
         MyBean myBean = new MyBean();
         myBean.setName(env.getProperty("bean.name"));
         return myBean;
     }
 }

Using Property Sources

Properties resolved via Environment reside in one or more "property source" objects; @Configuration may work with specific property files. 
@Configuration
@PropertySource("classpath:/com/acme/app.properties")
 public class AppConfig {

     @Inject Environment env;

     @Bean
     public MyBean myBean() {
         return new MyBean(env.getProperty("bean.name"));
     }
 }

Using Value Injection

Without bypass the Environment, externalized values may be injected into @Configuration via @Value.
@Configuration
 @PropertySource("classpath:/com/acme/app.properties")
 public class AppConfig {

     @Value("${bean.name}") String beanName;

     @Bean
     public MyBean myBean() {
         return new MyBean(beanName);
     }
 }

Specifying @Component Location

@ComponentScan configures component scanning directives for use with @Configuration classes. 

@Configuration
 @ComponentScan("com.acme.app.services")
 public class AppConfig {
     // various @Bean definitions ...
 }


?About proxyBeanMethods

By default  @Configuration(proxyBeanMethods=true); it specifies whether @Bean methods should get proxied in order to enforce bean lifecycle behaviour, e.g to return shared singleton bean instances even in direct @Bean method calls in user code. This feature requires method interception, implemented through a runtime-generated CGLIB subclass which comes with limitations such as configuration class and its methods not being allowed to declare final.  
public abstract boolean proxyBeanMethods


Sunday, 18 October 2020

Adding Extra Property Files in Spring and SpringBoot

Register a Properties File via Java Annotations

 @PropertySource annotation, it is introduced since Spring 3.1, and used in conjunction with Java-based configuration and the @Configuration annotation. 


Another useful way to register a new properties file is by using a placeholder, which allows us to dynamically select the right file at runtime. 

${envTarget:mysql}


Defining Multiple Property Locations

The  @PropertySource annotation is repeatable according to Java 8 conventions. We can define multiple properties files and their locations. 

We can specify an array of @PropertySource; this works in any Java version.

Using/Injecting Properties

Injecting a property using the @Value annotation.

?? specify a default value for the property. 

We can obtain the value of a property using the Environment API
@Autowired
private Environment env; 
...
dataSource.setUrl(env.getProperty("jdbc.rul));


Properties with Spring Boot

Default Property File


This new support involves less configuration compared to standard Spring. 

application.properties: the Default Property File; doesn't need any arrangement


Environment-Specific Properties File

If we need to target different environments, application-environment.properties file in the src/main/resources directory, and then set a Spring profile with the same environment name. 

if we define a "staging" environment, we then have to define a stagging profile, and then application-stagging.properties. 

This env file will be loaded and will take precedence over the default property file. 


Test-Specific Properties File

Spring boot looks for test specific files in our src/test/resources directory during a test run. Again, default properties will still be injectable as normal but will be overridden by these test specific properties if there is a collision. 


@Runwith(SpringRunner.class)
@TestPropertySource("/foo.properties")


if we don't want to use a file, directly specify names and values.
@TestPropertySource(properties={"foo=bar"})

or it can achieve the same using
@RunWith(SpringRunner.class)
@SpringBootTest(
properties={"foo=bar"},classes=SpringBootPropertiesTestApplication.class)
)


Hierarchical Properties

we can mapping a group of properties from a file into a POJO, using @ConfiguartionProperties annotation.

Properties from Command Line Arguments

java -jar app.jar --property="value"

or via system properties, which are provided before the -jar command rather than after it
java -Dproperty.name="value" -jar app.jar

Properties from Environment Variables

export name=value
java -jar app.jar







 




 



Friday, 21 August 2020

Caused by: org.hibernate.TransientObjectException:

 Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.ynz.demobasicauthentication.entities.User



I met the same Exception, as handling many to many relationships.

my case is a user has many roles, while a role has many users.

the exception Is due to as persisting user, but its associated roles that haven’t been saved in the base; so the PK is not present. so the relationships cannot be built up.


solution:   I added cascade type then the exception was solved. 

@ManyToMany(cascade = CascadeType.PERSIST)








Thursday, 6 August 2020

Spring Boot Database Initialisation

Initialise a database using Hibernate

spring.jpa.hibernate.ddl-auto= [none, validate, update, create-drop] controls how to generate database tables. 

  • create: Hibernate first drops existing tables, then creates new tables.
  • update: Comparing with existing tables or columns in the database, and update the existing according to the diff. It never deletes the existing tables or columns even if they are no more required by the application.  
  • create-drop: similar to create, with the addition that Hibernate will drop the database after all operations are completed. Typically used for unit testing.  
  • validate: Hibernate only validate whether the tables and columns exist, otherwise it throws an exception.
  • none: this value effectively turns off the DDL generation. 

Spring boot may recognize database type and gives default value. 

If it finds that it is an embedded database: spring.jpa.hibernate.ddl-auto=create-drop; 
so maybe you need to turn it off; otherwise, hibernate will automatically create the schema in line with entities. 

If it finds that it is a real database, then spring.jpa.hibernate.ddl-auto=none; 
It will automatically find schema.sql and data.sql to create tables and populating data. 


spring.jpa.show-sql=true displaying SQL in the console. 
spring.jpa.properties.hibernate.format_sql=true Formatting the SQL

//doesn't work
spring.datasource.initialize=false turn off initialising using scripts.  


Spring Boot can automatically create the schema (DDL scripts) of your DataSource and initialize it (DML scripts). It loads SQL from the standard root classpath locations: schema.sql and data.sql, respectively. In addition, Spring Boot processes the schema-${platform}.sql and data-${platform}.sql files (if present), where platform is the value of spring.datasource.platform. This allows you to switch to database-specific scripts if necessary. For example, you might choose to set it to the vendor name of the database (hsqldb, h2, oracle, mysql, postgresql, and so on).


You can set spring.jpa.hibernate.ddl-auto explicitly and the standard Hibernate property values are none, validate, update, create, and create-drop. Spring Boot chooses a default value for you based on whether it thinks your database is embedded. It defaults to create-drop if no schema manager has been detected or none in all other cases. An embedded database is detected by looking at the Connection type. hsqldb, h2, and derby are embedded, and others are not. Be careful when switching from in-memory to a ‘real’ database that you do not make assumptions about the existence of the tables and data in the new platform. You either have to set ddl-auto explicitly or use one of the other mechanisms to initialize the database.


Spring provides a JPA-specific property which Hibernate uses for DDL generation: spring.jpa.hibernate.ddl-auto.

The standard Hibernate property values are: create, update, create-drop, validate and none:

create – Hibernate first drops existing tables, then creates new tables
update – the object model created based on the mappings (annotations or XML) is compared with the existing schema, and then Hibernate updates the schema according to the diff. It never deletes the existing tables or columns even if they are no more required by the application
create-drop – similar to create, with the addition that Hibernate will drop the database after all operations are completed. Typically used for unit testing
validate – Hibernate only validates whether the tables and columns exist, otherwise it throws an exception
none – this value effectively turns off the DDL generation
Spring Boot internally defaults this parameter value to create-drop if no schema manager has been detected, otherwise none for all other cases.



Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...