Сообщения

Сообщения за 2020

swagger openapi with spring security

pom.xml:    <dependency>             <groupId>org.springdoc</groupId>             <artifactId>springdoc-openapi-ui</artifactId>             <version>1.3.9</version>         </dependency>         <dependency>             <groupId>org.springdoc</groupId>             <artifactId>springdoc-openapi-security</artifactId>             <version>1.4.0</version>         </dependency> properties:  springdoc:     swagger-ui:         path: /swagger-ui.html     api-docs:         enabled: true         path: /v3/api-docs then go to the url:  http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs and explore http://localhost:8080/v3/api-docs  doc:  https://springdoc.org/faq.html

clear flyway migration on each junit test

@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, FlywayTestExecutionListener.class}) on test class and on every test @FlywayTest https://mvnrepository.com/artifact/org.flywaydb.flyway-test-extensions/flyway-spring-test src: https://stackoverflow.com/a/41929489/2910338  

hibernate session actionqueue clear

https://stackoverflow.com/questions/27755461/why-is-hibernate-batching-order-inserts-order-updates-disabled-by-default flush() следует применять только в тех случаях когда необходимо получать сохраненную версию объекта перед заверщением транзакции. clear() очищает hibernate сессию session.load update saveOrUpdate persist delete наполняют сессию различными обхектами в кеш 1го уровня. в actionQueue добавляются сущности для обработки при session.flush(). при закрытии сессии кеш 1го уровня очищается. int i=0; for(<1000 p="">i++; final Object entity = session.load(name,oid); session.delete(entity); if(i%20 ==0){ session.flush(); session.clear(); } } <1000 p=""> <1000 p=""> <1000 p=""> <1000 p="">************ lazy fields поля lazy работают только в рамках сессии - если сессию закрыли session.close() то lazyInitException. если используется @transactional то границами сессии управляет спринг. rppag