Skip to content

Instantly share code, notes, and snippets.

Avatar

Dennys dennysfredericci

View GitHub Profile
View GenderConverter.java
@Converter
public class GenderConverter implements AttributeConverter<Gender, String> {
@Override
public String convertToDatabaseColumn(Gender gender) {
return gender.getCode();
}
@Override
public Gender convertToEntityAttribute(String code) {
View Person.java
@Entity
public class Person {
@Id
private Long id;
private String firstName;
private String lastName;
@Convert(converter = GenderConverter.class)
private Gender gender;
View Gender.java
public enum Gender {
FEMALE("F"),
MALE("M"),
NOT_AVAILABLE("N");
private final String code;
Gender(String code) {
this.code = code;
View GenderConverter.java
@Converter
public class GenderConverter implements AttributeConverter<Gender, String> {
@Override
public String convertToDatabaseColumn(Gender gender) {
return gender.getCode();
}
@Override
public Gender convertToEntityAttribute(String code) {
View GenderConverter.java
@Converter(autoApply = true)
public class GenderConverter implements AttributeConverter<Gender, String> {
@Override
public String convertToDatabaseColumn(Gender gender) {
return gender.getCode();
}
@Override
public Gender convertToEntityAttribute(String code) {
View Gender.java
public enum Gender {
FEMALE,
MALE,
NOT_AVAILABLE;
}
View Person.java
@Entity
public class Person {
@Id
private Long id;
private String firstName;
private String lastName;
@Enumerated(EnumType.STRING)
private Gender gender;
@dennysfredericci
dennysfredericci / DemoApplication.java
Last active Nov 15, 2019
Example of Spring Bean in a Request Scope
View DemoApplication.java
package com.example.demo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
View LiquibaseGeneratorForFormulierOnderdeel.java
package be.schaubroeck.golf.liquibase.corrections;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.text.StrSubstitutor;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
@dennysfredericci
dennysfredericci / gist:890c5d76e84de91d52a9f88df0965588
Created Aug 17, 2018
Add Twitter Bootstrap at Angular Project
View gist:890c5d76e84de91d52a9f88df0965588
1. Create angular project
ng new my-app
2. Install bootstrap dependencies
npm install --save @ng-bootstrap/ng-bootstrap bootstrap@4.1.3 font-awesome
3. Add the lines below in scripts array at angular.json