java - Prevent hibernate from generating all query plan on startup when using spring data jpa and rest -
i'm using spring info jpa, rest, hibernate entitymanager 4.3.6 spring boot, , initializing slow. more 1m+.
hibernate walks through attributes, , generate query on startup.
how can prevent this?
log: log file on github gist
bean definition:
@bean public localcontainerentitymanagerfactorybean entitymanagerfactory(datasource datasource) { localcontainerentitymanagerfactorybean em = new localcontainerentitymanagerfactorybean(); em.setdatasource(datasource); em.setpackagestoscan("com.ceram1.openauth.persistence.model"); jpavendoradapter vendoradapter = new hibernatejpavendoradapter(); em.setjpavendoradapter(vendoradapter); em.setjpaproperties(additionalproperties()); em.setsharedcachemode(sharedcachemode.all); homecoming em; }
properties config:
p.setproperty("hibernate.temp.use_jdbc_metadata_defaults", "false"); p.setproperty("hibernate.query.startup_check", "false"); p.setproperty("hibernate.show_sql", "true"); p.setproperty("hibernate.dialect", "org.hibernate.dialect.mysql5innodbdialect"); p.setproperty("jadira.usertype.autoregisterusertypes", "true"); p.setproperty("hibernate.connection.charset", "utf8"); p.setproperty("hibernate.connection.characterencoding", "utf8"); p.setproperty("hibernate.connection.useunicode", "true"); p.setproperty("hibernate.cache.use_second_level_cache", "false"); p.setproperty("hibernate.cache.use_query_cache", "false");
you can placing annotation entity(dynamicinsert=true, dynamicupdate=true) each class don't want query generated on startup. lengthy coding part. helpful if want that.
reference: hibernate recipe book.
but has performance issues @ runtime here: why hibernate dynamic insert=false default
here link: @dynamicinsert @dynamicupdate not work?
java spring hibernate spring-data-jpa spring-data-rest
No comments:
Post a Comment