Skip to content

Instantly share code, notes, and snippets.

View hermanwhyd's full-sized avatar

HermanW hermanwhyd

  • Jakarta, Indonesia
View GitHub Profile
@hermanwhyd
hermanwhyd / JavaOptional.java
Created February 21, 2020 07:13
Java Optional Snippet
package khannedy.javatipsweekly.optional;
import java.util.Optional;
public class JavaOptional {
public void nullCheck(Customer customer) {
String name = Optional.ofNullable(customer.getName())
.orElse("");
@hermanwhyd
hermanwhyd / mysql-getallchilds.sql
Last active September 29, 2019 07:30
MySQL Query Recursive Parent and child - Get All childs
-- mysql get all childs
select id,
name,
parent_id
from (select * from tablename
order by parent_id, id) tablename,
(select @pv := '100') initialisation
where find_in_set(parent_id, @pv) > 0
and @pv := concat(@pv, ',', id)