본문 바로가기

Programming!

Kotlin - Preconditions.kt 둘러보기 코드 작성시 만들어서 사용하기는 하지만, 공통으로 있으면 좋을 만한~~~ 것들이 있다. https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/util/Preconditions.kt GitHub - JetBrains/kotlin: The Kotlin Programming Language. The Kotlin Programming Language. . Contribute to JetBrains/kotlin development by creating an account on GitHub. github.com Spring Assert를 간혹 사용하기는 했는데 코틀린도 포함되어 있으니 사용하는 것으로 한다. Null Check 예제.. 더보기
기사 : hibernate-reactive 주말에 함 둘러보기 https://in.relation.to/2021/10/27/hibernate-reactive-1/ Hibernate Reactive 1.0.0.Final is now available - In Relation To Hibernate Reactive 1.0.0.Final is the first production-ready release of Hibernate Reactive, the only object-relational mapping solution that supports non-blocking database drivers and a reactive style of interaction with the database. Hibernate Reactive no in.relati.. 더보기
runCatching - kotlin 코틀린 예외처리를 보다가 흠.. 이런게 있구나.. 하고 남김. 특정 클래스에서 숫자형 문자를 반환하고 반환된 문자를 Int형으로 변경하는 상황으로 테스트코드 작성. internal class TextNumber { // 임의 Throw fun getThrow() : String { throw RuntimeException() } // 정상반환 fun getStringNumber() : String = "1000" } 예시: 기본적인 try ~ catch를 사용했을 경우 의 코드 ( 오래전.. ) internal class RunCatchingService { private val log = KotlinLogging.logger { } // throw fun getAsis() : Int { val text.. 더보기
List를 varargs( '...' ) Arguments로 처리해야 하는 경우 - Kotlin varargs로 받는 메소드를 사용시 List 처리를 해야 하는 경우가 생기고는 한다. 대표적으로 보면 queryDsl의 .orderBy(OrderSpecifier ...) 꼭 List로 뭔가 하는건 아닌데 정말 간혹 위와 같은 상황을 맞이하면 java에서는 대충 이런식이 될 듯 하다. ... .orderBy(orderSpecifiers.toArray(new OrderSpecifier[0])) ... 그럼 코틀린의 경우는 이런식이 되겠네..오호. '*' 이것을 주목하자 ... .orderBy(*orderSpecifiers.toTypedArray()) ... 더보기
MySQL : Order By RAND() - JPA QueryDSL JPA + QueryDSL 의 MySQL환경에서 정말 간혹 rand() 함수를 사용해서 order by를 걸고 싶을때가 있다. where(xxx) .orderBy(NumberExpression.random().asc()) .limit(100000) // 뭐 대충 이런... MySQL은 안된다. 별도의 Template를 만들던가 해야 하는데 그냥 가볍게 사용할거면 아래와 같이 하자. .where( WhereClauseBuilder.builder().build() ).orderBy( Expressions.numberTemplate(Double::class.java, "function('rand')").asc() ) 무겁게는 사용하지 말자. 더보기