問題タブ [table-per-class]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - Joined 戦略で @Inheritance を使用した Hibernate エラー「オブジェクトが見つかりません」
Hibernate で正しく動作する 3 つの Java クラス (BaseEntity、User、Role) があります。User と Role はどちらも BaseEntity のサブクラスです。ユーザー用のテーブルとロール用のテーブルがあります。ユーザーをロールにマッピングするための結合テーブルがあります。使用されるすべての注釈はjavax.persistence
注釈です。
さまざまな理由から、モデルを拡張し、Role のスーパークラスを作成する必要があります。このスーパークラスには自己参照が必要です。私の考えは、ここで結合された戦略で @Inheritance アノテーションを使用することでしたが、Hibernate からエラーが発生し続けます。私が読んだことから、Hibernate は、スーパークラスから属性を取得するために結合を行う必要があることを理解する必要があります。
私が得ているエラー:
[警告] [18:30:04.004] [] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL エラー: -5501、SQLState: 42501 [エラー] [18:30:04.004] [] org.hibernate.engine .jdbc.spi.SqlExceptionHelper - ユーザーに権限がないか、オブジェクトが見つかりません: ROLE1_.NAME
Hibernate SQL 出力:
休止状態 4.2.19 を使用しています
ご覧のとおり、Hibernate は権限テーブルから name 属性の値を選択しようとしていますが、これは正しいのですが、その列がそのテーブルに存在しないと不平を言っています。
この問題を解決するにはどうすればよいですか?
c# - Entity Framework Code First - 継承 - 関連項目 コレクション
継承を使用して EF6 でモデルを実装しようとしています
私は次のクラスを持っています:
Base
Comments
Page : Base
BlogPost : Base
Page と BlogPost の両方が同じ方法でコメントを使用する場合。だから私はベースを次のように定義します
そして、次のように定義されたコメント クラス:
データベースを「タイプごとのテーブル」としてセットアップしたいとします。そのため、自動インクリメント int PK を持つ Page と BlogPost のそれぞれに個別のテーブルがあります。
これで、EF は Comment.RelatedItemID が指しているテーブルを認識しましたか? つまり、ページまたはブログ投稿
「階層ごとのテーブル」に頼らずにこれを実装する最良の方法は何ですか?
java - Hibernate クエリはサブクラスからデータを取得します
具体的なクラス戦略ごとにテーブルを使用しています
これで 3 つのテーブルが作成されました
しかし、使用してデータベースにクエリを実行すると
Hibernate は 3 つのテーブルすべてに対してユニオン クエリを発行しますが、なぜこのようになるのでしょうか? 私はちょうど車両を求めています。
java - InheritanceType.TABLE_PER_CLASS で列名をオーバーライドする
TABLE_PER_CLASS 継承が使用されている場合、列名をオーバーライドする方法はありますか?
ドキュメントには、
「このアプローチの制限は、プロパティがスーパークラスにマップされている場合、列名がすべてのサブクラス テーブルで同じでなければならないことです」とあります。:(
@AttributeOverride が機能しない
例:
およびいくつかのサンプルクエリ
生産する
子サブクエリで Hibernate にカスタム プロパティ名を強制的に使用させる方法はありますか? 問題は、ほとんど同じデータを保持するいくつかのテーブルを持ついくつかのレガシー DB がありますが、一部の列名が異なることです...
編集:名前が変更された列名を含むビューになってしまいました
hibernate - An issue when I use unidirectional One-To-Many and Table Per Class InheritanceType in Hibernate
I have a class Person
and a class hierarchy which has three classes, when I use InheritanceType.TABLE_PER_CLASS for the class hierarchy, it got the "Batch update" problem. Please see the below code. AbstractBase
is the base class for the class hierarchy.
Test code:
Output:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1"
I found that Hibernate doesn't update the Manager
table when I went through the hibernate sql. When I changed the InheritanceType to InheritanceType.JOINED
, the code works well. Do I miss something in the unidirectional One-To-Many configuration?
----------------------------------update--------------------------------
In 'Person' class, I changed @JoinColumn to @JoinTable in One-To-Many annotation, the testing code works well. Is there any missed configuration for @JoinColumn configuration when its target class is annotated by "InheritanceType.TABLE_PER_CLASS"?
See below detailed annotation:
-------------------------------------update--------------------------------
I tried the code with Hibernate 5.2.5 Final, the issue still exists.