This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <configuration debug="true"> | |
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| <encoder> | |
| <pattern> | |
| %green(%date) %highlight(%-5level) %magenta([%thread]) %cyan(%logger{10}) %blue(: %msg%n) | |
| </pattern> | |
| <charset>UTF-8</charset> | |
| </encoder> | |
| </appender> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| The issue is within exchanged formats between HAL browser and (SpringBoot) app. | |
| To fix it, use `accept application/hal+json` in HAL. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.springframework.boot.context.properties.ConfigurationProperties | |
| import org.springframework.context.annotation.Configuration | |
| import org.springframework.context.annotation.PropertySource | |
| import kotlin.properties.Delegates | |
| @Configuration | |
| @PropertySource( | |
| value = ["\${app.processing.configuration}"], // file:/folder/processing-config.yml | |
| factory = YamlPropertySourceFactory::class, | |
| encoding = "UTF-8" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.github.lachlan.xml.splitter; | |
| public class Main { | |
| public static final int BUFFER_SIZE = 8192; | |
| public static void main(String[] args) { | |
| Main main = new Main(); | |
| if (args.length < 2) { | |
| System.out.println("Usage: "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Выясняем номер последней страницы (макс кол-во страниц) */ | |
| public int getLastApprovedPageNumber(int pageSize) { | |
| String genericClassName = persistentClass.toGenericString(); | |
| genericClassName = genericClassName.substring(genericClassName.lastIndexOf('.') + 1); | |
| String jql = "Select count(*) from " + genericClassName + " WHERE isApproved = true"; | |
| Query query = entityManager.createQuery(jql); | |
| long count = (long) query.getSingleResult(); | |
| int lastPageNumber = (int) ((count / pageSize) + 1); | |
| return lastPageNumber; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public List<Song> getByCreatedDateRange(Timestamp dateFrom, Timestamp dateTo) { | |
| return entityManager | |
| .createQuery("FROM Song s WHERE s.createdAt >= :dateFrom AND s.createdAt <= :dateTo ORDER BY s.createdAt", Song.class) | |
| .setParameter("dateFrom", dateFrom) | |
| .setParameter("dateTo", dateTo).getResultList(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| @Transactional(propagation= Propagation.MANDATORY) | |
| public void bulkDeleteByUserId(Long id) { | |
| // Write all pending changes to the DB | |
| entityManager.flush(); | |
| // Remove all entities from the persistence context | |
| entityManager.clear(); | |
| entityManager.createQuery("DELETE FROM StudentReviewAnswer x " + | |
| "WHERE x IN (SELECT sra FROM StudentReviewAnswer sra " + | |
| "JOIN StudentReview sr ON sra.studentReview.id = sr.id " + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | |
| // можно использовать и копировать между классами. Но тогда источник будет иметь полный путь класса, а это не всегда удобно | |
| // http://slf4j.org/faq.html#declared_static |