アプリケーション サーバーのネイティブ パフォーマンス関連の統計を収集する自家製ソリューションのダッシュボードを作成しようとしています。さまざまなエージェントによって収集されたデータの DDL は次のとおりです。簡潔にするために、いくつかの列と関連のない表をスキップしました。
create table server (
id integer not null auto_increment,
name varchar(50) not null,
primary key(id)
);
create table metric (
id integer not null auto_increment,
name varchar(50) not null,
primary key (id)
);
create table server_metric (
id integer not null auto_increment,
server_id integer not null,
metric_id integer not null,
constraint foreign key (server_fk) references server(id),
constraint foreign key (metric_fk) references metric(id),
primary key (id)
);
create table value (
id integer not null auto_increment,
server_metric_id integer not null,
value varchar(500) not null,
collect_time timestamp not null,
constraint foreign key (server_metric_fk) references server_metric(id)
primary key (id)
);
ダッシュボードでは、基準の一部として、これらのテーブルの任意の列に基づくレポートをユーザーが表示できるようにする必要があります。そこで、ユーザーの選択に基づいて Hibernate Criteria クエリを生成します。
POJO をリバース エンジニアリングすると、Metric オブジェクトは次のようになります。
private long id;
private String name;
private Set serverMetrics = new HashSet(0);
... constructors, getters, setters truncated ...
私がやりたいことは、メトリックを上記のテーブルの関係の単一の POJO として公開することです。したがって、基本的に、Metric POJO を介してサーバーの名前、値、タイムスタンプをすべて取得できます。これは単純に Criteria クエリを生成し、結果セットは常に Metric オブジェクトのリストになります。
このリンクを参照しました。これは、オブジェクト間の 1 対 1 の関係でうまく機能します。しかし、私の場合、メトリックはserver_metricなどと1対多の関係にあります...メトリックテーブルのマッピングファイルが同じことを達成する方法がわかりません
どんな助けでも大歓迎です...
乾杯!!