Last active
April 3, 2020 08:21
-
-
Save bnbaek/da6c97b9d353c4e067985a2385f44132 to your computer and use it in GitHub Desktop.
enum-jpa-use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.barogo.zoo.core.repository.test; | |
import io.barogo.zoo.core.repository.test.converter.CoffeeTypeConverter; | |
import javax.persistence.Column; | |
import javax.persistence.Convert; | |
import javax.persistence.Entity; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
import javax.persistence.Id; | |
import javax.persistence.Table; | |
import lombok.AccessLevel; | |
import lombok.Getter; | |
import lombok.NoArgsConstructor; | |
import lombok.ToString; | |
/** | |
* Created by BNBAEK | |
* Package : io.barogo.zoo.core.repository.test | |
* User: dean | |
* Date: 2020/04/03 | |
* Time: 3:30 오후 | |
*/ | |
@Entity | |
@Table(name = "ZOO_COFFEE") | |
@ToString | |
@Getter | |
@NoArgsConstructor(access = AccessLevel.PROTECTED) | |
public class Coffee { | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
@Column(name = "coffee_id") | |
private Long id; | |
@Convert(converter = CoffeeTypeConverter.class) | |
private CoffeeType type; | |
public Coffee(CoffeeType type) { | |
this.type = type; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.barogo.zoo.core.repository.test; | |
import java.util.Optional; | |
import org.springframework.data.jpa.repository.JpaRepository; | |
/** | |
* Created by BNBAEK | |
* Package : io.barogo.zoo.core.repository.test | |
* User: dean | |
* Date: 2020/04/03 | |
* Time: 3:57 오후 | |
*/ | |
public interface CoffeeRepository extends JpaRepository<Coffee, Long> { | |
Optional<Coffee> findByType(CoffeeType message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.barogo.zoo.core.repository.test; | |
import io.barogo.zoo.core.repository.test.common.LegacyCommonType; | |
import lombok.Getter; | |
/** | |
* Created by BNBAEK | |
* Package : io.barogo.zoo.core.repository.test | |
* User: dean | |
* Date: 2020/04/03 | |
* Time: 3:33 오후 | |
*/ | |
@Getter | |
public enum CoffeeType implements LegacyCommonType { | |
COMPULSION("강제배차", "0") | |
, NOTIFICATION("공지", "1") | |
, MESSAGE("메시지", "2") | |
, IMMEDIATE_DISPATCH("즉시배차", "3"); | |
private String desc; | |
private String legacyCode; | |
CoffeeType(String desc | |
, String legacyCode) { | |
this.desc = desc; | |
this.legacyCode = legacyCode; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment