params.put("status", Snapshot.STATUS_PROCESSED);
params.put("lib", Qualifiers.LIBRARY);
- sb.append(" AND m.characteristic IS NULL");
+ sb.append(" AND m.characteristicId IS NULL");
sb.append(" AND m.personId IS NULL");
sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL");
if (!metricIds.isEmpty()) {
measure.setVariation4(model.getVariationValue4());
measure.setVariation5(model.getVariationValue5());
measure.setUrl(model.getUrl());
- measure.setCharacteristic(model.getCharacteristic());
- measure.setPersonId(model.getPersonId());
return measure;
}
}
model.setVariationValue4(measure.getVariation4());
model.setVariationValue5(measure.getVariation5());
model.setUrl(measure.getUrl());
- model.setCharacteristic(measure.getCharacteristic());
+ if (measure.getCharacteristic()!=null) {
+ model.setCharacteristicId(measure.getCharacteristic().getId());
+ }
model.setPersonId(measure.getPersonId());
if (measure.getValue() != null) {
model.setValue(measure.getValue().doubleValue());
*/
package org.sonar.api.database.model;
+import com.google.common.base.Preconditions;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.rules.RulePriority;
import javax.persistence.*;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@OneToMany(mappedBy = "measure", fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
private List<MeasureData> measureData = new ArrayList<MeasureData>();
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "characteristic_id")
- private Characteristic characteristic;
+ @Column(name = "characteristic_id", updatable = true, nullable = true)
+ private Integer characteristicId;
@Column(name = "person_id", updatable = true, nullable = true)
private Integer personId;
return this;
}
+ public Integer getCharacteristicId() {
+ return characteristicId;
+ }
+
+ public MeasureModel setCharacteristicId(Integer i) {
+ this.characteristicId = i;
+ return this;
+ }
+
+ /**
+ * @deprecated replaced by {@link org.sonar.api.database.model.MeasureModel#getCharacteristicId()} since 3.3. See https://jira.codehaus.org/browse/SONAR-3778
+ */
+ @Deprecated
public Characteristic getCharacteristic() {
- return characteristic;
+ Characteristic c = null;
+ if (characteristicId != null) {
+ c = Characteristic.create().setId(characteristicId);
+ }
+ return c;
}
+ /**
+ * @deprecated replaced by {@link org.sonar.api.database.model.MeasureModel#setCharacteristicId(Integer)} since 3.3. See https://jira.codehaus.org/browse/SONAR-3778
+ */
+ @Deprecated
public MeasureModel setCharacteristic(Characteristic c) {
- this.characteristic = c;
+ if (c == null) {
+ this.characteristicId = null;
+ } else {
+ Preconditions.checkArgument(c.getId()!=null, "Characteristic id must not be null");
+ this.characteristicId = c.getId();
+ }
return this;
}
clone.setSnapshotId(getSnapshotId());
clone.setMeasureDate(getMeasureDate());
clone.setUrl(getUrl());
- clone.setCharacteristic(getCharacteristic());
+ clone.setCharacteristicId(getCharacteristicId());
clone.setPersonId(getPersonId());
return clone;
}