aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-04-24 18:05:36 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-04-24 18:06:12 +0200
commit478383011bba15b19869380384aa569697706681 (patch)
tree1f0f66340ab9ea018b73049cbb836e5eb7a4731e /sonar-core/src
parent26680d528d424837683d5a1edf4e3c7f85c53d92 (diff)
downloadsonarqube-478383011bba15b19869380384aa569697706681.tar.gz
sonarqube-478383011bba15b19869380384aa569697706681.zip
Revert "SONAR-3437 Remove Measure from Hibernate model"
This reverts commit cafd76d5317716817c0f15a402d820a6e80d19a9.
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/resources/META-INF/persistence.xml2
-rw-r--r--sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java34
2 files changed, 28 insertions, 8 deletions
diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml
index 79a9ad22f6b..034e3dffd10 100644
--- a/sonar-core/src/main/resources/META-INF/persistence.xml
+++ b/sonar-core/src/main/resources/META-INF/persistence.xml
@@ -11,6 +11,8 @@
<class>org.sonar.api.database.configuration.Property</class>
<class>org.sonar.api.database.model.User</class>
<class>org.sonar.api.database.model.Snapshot</class>
+ <class>org.sonar.api.database.model.MeasureModel</class>
+ <class>org.sonar.api.database.model.MeasureData</class>
<class>org.sonar.api.design.DependencyDto</class>
<class>org.sonar.api.measures.Metric</class>
<class>org.sonar.api.database.model.ResourceModel</class>
diff --git a/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java b/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java
index 54d57081e68..99bb844283e 100644
--- a/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java
+++ b/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java
@@ -23,20 +23,19 @@ import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.internal.matchers.IsCollectionContaining;
+import org.sonar.api.database.model.MeasureModel;
import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Metric;
+import org.sonar.jpa.dao.MeasuresDao;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import javax.persistence.NonUniqueResultException;
-
+import java.sql.Date;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
public class DatabaseSessionTest extends AbstractDbUnitTestCase {
private static final Long NB_INSERTS = 20000l;
@@ -51,6 +50,25 @@ public class DatabaseSessionTest extends AbstractDbUnitTestCase {
}
@Test
+ public void performanceTestOnBatchInserts() throws Exception {
+ getSession().save(project1);
+ Snapshot snapshot = new Snapshot(project1, true, "", new Date(1));
+ getSession().save(snapshot);
+ getSession().save(CoreMetrics.CLASSES);
+ getSession().commit();
+
+ Metric metric = new MeasuresDao(getSession()).getMetric(CoreMetrics.CLASSES_KEY);
+ for (int i = 0; i < NB_INSERTS; i++) {
+ MeasureModel pm = new MeasureModel(metric.getId(), 1.0).setSnapshotId(snapshot.getId());
+ getSession().save(pm);
+ }
+
+ getSession().commit();
+ assertEquals(NB_INSERTS, getHQLCount(MeasureModel.class));
+
+ }
+
+ @Test
public void testGetSingleResultWithNoResults() {
assertNull(getSession().getSingleResult(ResourceModel.class, "name", "test"));
}