Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgresDialectでID生成エラーが発生する問題を修正 #74

Merged
merged 1 commit into from
Apr 25, 2015

Conversation

nakamura-to
Copy link
Member

Dialect#getIdentitySelectSql のシグニチャを変更し、引用符で囲む前の名前を受け取るようにしました。
PostgresDialect の実装では、 @Table(quote = true) の場合、シーケンス名を作成した後で、カタログ名、スキーマ名、シーケンス名をそれぞれ引用符で囲み連結します。

@Table(catalog = "catalog_name", schema = "schema_name",  name = "table_name", quote = true)
public class TableName {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    Long id;
}

上記のエンティティクラスに対応するID取得のSQLは次のようになります。

select currval('"catalog_name"."schema_name"."table_name_id_seq"');

fixed #73

`Dialect#getIdentitySelectSql` のシグニチャを変更し、引用符で囲む前の名前を受け取るようにしました。
`PostgresDialect` の実装では、 `@Table(quote = true)` の場合、シーケンス名を作成した後で、カタログ名、スキーマ名、シーケンス名をそれぞれ引用符で囲み連結します。

```java
@table(catalog = "catalog_name", schema = "schema_name",  name = "table_name", quote = true)
public class TableName {
    @id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @column(name = "id")
    Long id;
}
```

上記のエンティティクラスに対応するID取得のSQLは次のようになります。

```sql
select currval('"catalog_name"."schema_name"."table_name_id_seq"');
```

fixed #73
nakamura-to added a commit that referenced this pull request Apr 25, 2015
PostgresDialectでID生成エラーが発生する問題を修正
@nakamura-to nakamura-to merged commit ced9108 into master Apr 25, 2015
@nakamura-to nakamura-to deleted the issue-73 branch April 25, 2015 06:07
@nakamura-to nakamura-to added this to the 2.3.0 milestone May 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostgresDialect で @Table(quote=true), GenerationType.IDENTITY のEntityでID生成エラーが発生する
1 participant