Skip to content

Commit

Permalink
Add the enum strategy type
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed Sep 23, 2023
1 parent 6d68c5b commit cf92225
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions content/en/docs/Reference/annotation-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ name
ordinal
: map the `ordinal` property of `Enum` class to the integer type column.

type
: map the `Enum` class to the enum type column.
Note that a [user-defined data type]({{< relref "data-type#user-defined-data-types" >}}) corresponding to the Enum class is required.

### komapper.namingStrategy

This option specifies the strategy for how to resolve database table and column names
Expand Down
6 changes: 5 additions & 1 deletion content/en/docs/Reference/entity-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ Explicitly specifies how to map the enum property to the column.

```kotlin
@KomapperEnum(EnumType.ORDINAL)
val color: Nothing // Assume that this color property corresponds to the Color enum class
val color: Color // Assume that this color property corresponds to the Color enum class
```

The `type` property of `@KomapperEnum` can be one of the following:
Expand All @@ -494,6 +494,10 @@ EnumType.PROPERTY
: map an arbitrary property of `Enum` class to the column.
The name of the property to be mapped must be specified in the `hint` property of `@KomapperEnum`.

EnumType.TYPE
: map the `Enum` class to the enum type column.
Note that a [user-defined data type]({{< relref "data-type#user-defined-data-types" >}}) corresponding to the Enum class is required.

```kotlin
enum class Color(val code: String) { RED("r"), GREEN("g"), BLUE("b") }

Expand Down
4 changes: 4 additions & 0 deletions content/ja/docs/Reference/annotation-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ name
ordinal
: Enumクラスの`ordinal`プロパティを整数型のカラムにマッピングする。

type
: Enumクラスをenum型のカラムにマッピングする。
Enumクラスに対応する [ユーザー定義のデータ型]({{< relref "data-type#user-defined-data-types" >}}) が必要であることに注意してほしい。

### komapper.namingStrategy

Kotlinのエンティクラスとプロパティからデータベースのテーブルとカラムの名前をどう解決するのかの戦略です。
Expand Down
6 changes: 5 additions & 1 deletion content/ja/docs/Reference/entity-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ Enum型のプロパティに対し、プロパティとカラムのマッピン

```kotlin
@KomapperEnum(EnumType.ORDINAL)
val color: Nothing // このcolorプロパティがColorというEnum型に対応すると想定してください
val color: Color // このcolorプロパティがColorというEnum型に対応すると想定してください
```

`@KomapperEnum``type`プロパティには次のいずれかを指定できます。
Expand All @@ -486,6 +486,10 @@ EnumType.PROPERTY
: Enumクラスの任意のプロパティをカラムにマッピングする。
マッピング対象のプロパティ名は`@KomapperEnum``hint`プロパティに指定する必要がある。

EnumType.TYPE
: Enumクラスをenum型のカラムにマッピングする。
Enumクラスに対応する [ユーザー定義のデータ型]({{< relref "data-type#user-defined-data-types" >}}) が必要であることに注意してほしい。

```kotlin
enum class Color(val code: String) { RED("r"), GREEN("g"), BLUE("b") }

Expand Down

0 comments on commit cf92225

Please sign in to comment.