본문 바로가기

분류 전체보기

(54)
JPA에서 entity가 update가 아닌 insert가 되는 경우 결론:Entity의 colmun이 primary key이기 때문에 Entity의 colmun이 기존에 저장된 값과 다르면 새로운 행으로 인식되어 insert가 되는 것이다 -- 내용 -- 위와 같은 entity가 있다 치고 ExampleEntity exampleEntity = exampleRepository.findFirstByOrderByColumnAsc(); if (exampleEntity == null) { exampleEntity = new ExampleEntity(); } exampleEntity.setColmun(BigInteger.valueOf(12345)); exampleRepository.save(exampleEntity); 아래 같은 로직이 있다 치자 entity가 null이 라면 ne..
가변인자 사용해서 자바에서 디폴트 매개 변수 흉내내기 파이썬에선 디폴트 매개변수를 사용해서 파라미터를 생략 할 수 있다. 이를 정말 유용하게 썼었지만 자바에는 이런 기능이 없다. 그래서 한번 비슷하게 하는법 public String sampleMethod(String name, String id, long... age) { ... if (age.length == 0) { // set defualt } ... } 이런식으로 age를 가변인자로 박으면 어느정도 default 변수처럼 흉내 낼 수 있다... 추가로 Arrays.stream(age).sum()) .. 같이 스트림을 자기 상황에 맞게 쓰면 더 편할 수 있다
@JSONSETTER 이용 중 삽질 기존 코드 @Data @NoArgsConstructor public class MetaData { ... @JsonSetter("attributes") public void setCategory(List attributes) { Class clazz = this.getClass(); for(Map attribute : attributes){ String traitType = (String) attribute.get("trait_type"); String traitValue = (String) attribute.get("value"); try { Field field = clazz.getDeclaredField(traitType.toLowerCase()); field.setAccessible(true); ..
opensea에 메타데이터json 보기 opensea에 올라가 있는 nft의 MetaData를 엿보자 1. OpenSea에서 맘에 드는 NFT 클릭 2. 해당 NFT의 details을 찾는다 위 사진과 같이 Token ID에 링크가 걸려 있는 경우 해당 링크를 누르면 Json 파일로 이동되는 경우가 있다. 한번씩 눌러보자 3. 이제 필요한 정보는 모두 찾았다. docs를 살펴보자 https://docs.opensea.io/docs/4-debugging-your-metadata - api.opensea.io/asset/{Contract Address}/{Token ID} 우리에게 필요한 api다 - 위 예제 NFT로 치면 아래와 같다 api.opensea.io/asset/0xC6B2Db94BD37C1C79012fe89454a4259137EEfE..
EC2 서버 용량 키우기 (볼륨 늘리기) 1. 용량 늘리기 (볼륨 늘리기) https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/requesting-ebs-volume-modifications.html 2. 용량 적용하기 (서버 파티션 볼륨 늘리기) https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html - 추가 사항 서버 용량이 이미 꽉차 있는 경우에 남은 공간이 없어서 오류가 난다. https://aws.amazon.com/ko/premiumsupport/knowledge-center/ebs-volume-size-increase/ $ sudo mount -o size=10M,rw..
db 세팅 어케해야할까 tool (heidiSQL)을 사용해서 db 세팅을 했었다. 직관적이고 익숙했기 때문이다. 근데 같은 내용의 db가 local, dev, oper 3개로 나눠져 있었고 local에서 수작업으로 세팅을 하고 테스트 한 후 dev, oper쪽 table을 날리고 local db백업을 밀어 넣는 식으로 했었다. 하지만 사용 중인 db에선 그렇게 작업하기가 무리가 있지 않나 싶었다. 그게 아니면 dev, oper에서도 수작업으로 똑같이 세팅을 해야하는데 이렇게 일일히 수작업으로 설정하다보니 중간에 실수로 빠트리기는 경우가 빈번했다. 그래서 jpa ddl-auto를 이용해서 ddl을 날리는 방법을 사용할까 싶었다. 변경 이력을 git에 남길 수도 있고 local, dev, oper에서 배포만하면 db가 동일하게 ..
[web3j] getTransactionCount https://ethereum.stackexchange.com/questions/115600/web3js-gettransactioncount-always-return-1 getTransactionCount: " + txcount ); }); Always return 1, but my contract has lot of" data-og-host="ethereum.stackexchange.com" data-og-source-url="https://ethereum.stackexchange.com/questions/115600/web3js-gettransactioncount-always-return-1" data-og-url="https://ethereum.stackexchange.com/questions/11..
web3j (web3 java)에서 isAddress 쓰기 import org.web3j.crypto.Keys; import org.web3j.crypto.WalletUtils; ... public boolean isAddress(String address) { if (!WalletUtils.isValidAddress(address)) return false; // lower case 는 컨트렉트에서 자동으로 checksum으로 변환된다 따라서 true로 판단한다 if (address.equals(address.toLowerCase())) return true; if (address.equals(Keys.toChecksumAddress(address))) return true; return false; } WalletUtils.isValidAddress는 그냥 ..