본문 바로가기

java34

자바 Jpa Entity -> Sql Default Value 별로 중요하지 않다고 생각하는 내용이었지만 작업 중 1분간 생각이 안나서 정리 create_time에 기본값을 설정하려 한다. 하지만 Jpa에서 Insert를 할 경우. null 값으로 인한 오류가 발생. @Data @DynamicInsert public class BuildingMaterialsEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int idx; Entity에 @DynamicInsert를 추가한다. DynamicUpdate도 있는걸로 보아, update시 사용하면 될듯. 2022. 9. 21.
자바 Jpql dynamic query @Query(value = "SELECT * FROM t_building_materials WHERE partner_code = :partnerCode ", nativeQuery = true) List getBuildingMaterialsEntityByNumber(@Param("partnerCode") String partnerCode); 일반적으로 Repository에 간단하게 추가하면 됨. 기본 동작이 아닌 경우 조회인 경우 매개변수가 없을 경우가 존재하므로 따로 조회해야 함. @PersistenceContext EntityManager entityManager; String partnerCode = redisUserInformation.getPartnerCode(); String jpql = " S.. 2022. 9. 21.
자바 비밀번호 생성(금융보안원) import java.util.ArrayList; import java.util.List; public class PasswordValidation { //220510 nhm, public static boolean isPasswordInvalid(String password, String email, String birth, String cellNo, int characterCheckCount) { //비밀번호 길이 if(!isPasswordRange(password)) { return false; } //알파벳 대문자와 소문자, 숫자, 특수문자 중 두 종류 이상 포함 if(!isContainsPasswordType(password)) { return false; } //계정명· 고유식별번호·생년월일·.. 2022. 5. 10.
Java 토마토 final static int[] xArray = {1, 0, -1, 0}; final static int[] yArray = {0, 1, 0, -1}; public static class Node { int x; int y; public Node(int x, int y) { this.x = x; this.y = y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public int getX() { return this.x; } public int getY() { return this.y; } } public static void main(String[] args) { tomato(); } private .. 2021. 12. 20.