Skip to content

Instantly share code, notes, and snippets.

View dennysfredericci's full-sized avatar

Dennys dennysfredericci

View GitHub Profile
@Converter
public class GenderConverter implements AttributeConverter<Gender, String> {
@Override
public String convertToDatabaseColumn(Gender gender) {
return gender.getCode();
}
@Override
public Gender convertToEntityAttribute(String code) {
@Entity
public class Person {
@Id
private Long id;
private String firstName;
private String lastName;
@Convert(converter = GenderConverter.class)
private Gender gender;
public enum Gender {
FEMALE("F"),
MALE("M"),
NOT_AVAILABLE("N");
private final String code;
Gender(String code) {
this.code = code;
@Converter
public class GenderConverter implements AttributeConverter<Gender, String> {
@Override
public String convertToDatabaseColumn(Gender gender) {
return gender.getCode();
}
@Override
public Gender convertToEntityAttribute(String code) {
@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) {
public enum Gender {
FEMALE,
MALE,
NOT_AVAILABLE;
}
@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 November 15, 2019 10:57
Example of Spring Bean in a Request Scope
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;
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 August 17, 2018 09:44
Add Twitter Bootstrap at Angular Project
1. Create angular project
ng new my-app
2. Install bootstrap dependencies
npm install --save @ng-bootstrap/ng-bootstrap [email protected] font-awesome
3. Add the lines below in scripts array at angular.json