Skip to content
Snippets Groups Projects
Commit 04f1f32a authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Merge branch 'jr/feature-db-indices' into 'master'

Indices for foreign keys with new hibernate version

Integrating !15 into the master for later 2.4 release

See merge request !16
parents beebe6b5 c4c7e5dd
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
......@@ -32,7 +33,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "custom_measurements")
@Table(name = "custom_measurements", indexes = { @Index(columnList = "hostMetricId", name = "hostMetricId") })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class CustomMeasurement implements HostMetricBound {
/**
......
......@@ -6,9 +6,9 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Type;
/** Database representation of an experiment, that is, a simulator run.
......@@ -25,14 +25,13 @@ import org.hibernate.annotations.Type;
* @version 1.0, 07/05/2011
*/
@Entity
@Table(name = "experiments")
@Table(name = "experiments", indexes = { @Index(columnList = "id", name = "id") })
public class Experiment {
/**
* A unique id of this experiment, which will be set by the database.
*/
@Id
@GeneratedValue
@Index(name = "id")
private int id;
/**
......
......@@ -3,14 +3,16 @@ package de.tud.kom.p2psim.impl.util.db.metric;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
@Entity
@Table(name = "hostmetrics")
@Table(name = "hostmetrics", indexes = {
@Index(columnList = "id", name = "id"),
@Index(columnList = "hostId", name = "hostId"),
@Index(columnList = "metricId", name = "metricId") })
/** Database mapping between metrics and hosts.
*
* This class is a POJO that maps to a table in a database. Instances
......@@ -23,14 +25,12 @@ public class HostMetric {
@SuppressWarnings("unused")
@Id
@GeneratedValue
@Index(name = "id")
private int id;
private long hostId;
@ManyToOne
@JoinColumn(name = "metricId")
@Index(name = "metricId")
private Metric metric;
protected HostMetric() {
......
......@@ -5,12 +5,11 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
/** Statistical representation of a series of measurements in the database.
*
* This class is a POJO that maps to a table in a database. Instances
......@@ -20,7 +19,7 @@ import org.hibernate.annotations.Index;
* @author Andreas Hemel
*/
@Entity
@Table(name = "measurements")
@Table(name = "measurements", indexes = { @Index(columnList = "id", name = "id") })
public class Measurement implements HostMetricBound {
/**
* The id of this table
......@@ -28,7 +27,6 @@ public class Measurement implements HostMetricBound {
@SuppressWarnings("unused")
@Id
@GeneratedValue
@Index(name = "id")
private int id;
/**
......
......@@ -4,11 +4,11 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
......@@ -23,7 +23,7 @@ import org.hibernate.annotations.OnDeleteAction;
* @author Andreas Hemel
*/
@Entity
@Table(name = "measurements_pair")
@Table(name = "measurements_pair", indexes = { @Index(columnList = "id", name = "id") })
public class MeasurementPair {
/**
* A unique Id, will be set by the database
......@@ -31,7 +31,6 @@ public class MeasurementPair {
@SuppressWarnings("unused")
@Id
@GeneratedValue()
@Index(name = "id")
private int id;
/**
......
......@@ -4,11 +4,11 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
......@@ -18,14 +18,13 @@ import org.hibernate.annotations.OnDeleteAction;
* @author Björn Richerzhagen
*/
@Entity
@Table(name = "measurements_pairlist")
@Table(name = "measurements_pairlist", indexes = { @Index(columnList = "id", name = "id") })
public class MeasurementPairList {
/**
* A unique Id, will be set by the database
*/
@Id
@GeneratedValue()
@Index(name = "id")
private int id;
/**
......
......@@ -4,12 +4,11 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
/** Statistical representation of a series of measurements in the database.
*
* This class is a POJO that maps to a table in a database. Instances
......@@ -23,7 +22,9 @@ import org.hibernate.annotations.Index;
* @author Andreas Hemel
*/
@Entity
@Table(name = "measurements_single")
@Table(name = "measurements_single", indexes = {
@Index(columnList = "time", name = "time"),
@Index(columnList = "hostMetricId", name = "hostMetricId") })
public class MeasurementSingle {
/**
* A unique Id, will be set by the database
......@@ -53,7 +54,6 @@ public class MeasurementSingle {
@SuppressWarnings("unused")
@ManyToOne
@JoinColumn(name = "hostMetricId")
@Index(name = "hostMetricId")
private HostMetric hostMetric;
/**
......
......@@ -4,12 +4,11 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
/** Database representation of a metric.
*
* It is nearly an exact equivalent of {@link MetricDescription} but
......@@ -23,7 +22,8 @@ import org.hibernate.annotations.Index;
* @author Andreas Hemel
*/
@Entity
@Table(name = "metrics")
@Table(name = "metrics", indexes = { @Index(columnList = "id", name = "id"),
@Index(columnList = "experimentId", name = "experimentId") })
public class Metric {
/**
* The unique id for this table, which is created by the database
......@@ -31,7 +31,6 @@ public class Metric {
@SuppressWarnings("unused")
@Id
@GeneratedValue
@Index(name = "id")
private int id;
/**
......@@ -68,7 +67,6 @@ public class Metric {
*/
@ManyToOne
@JoinColumn(name = "experimentId")
@Index(name = "experimentId")
private Experiment experiment;
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment