From 62c161fda2ac9055da089e5e3f611554c8487a58 Mon Sep 17 00:00:00 2001 From: lvca Date: Thu, 19 May 2016 21:24:35 +0200 Subject: [PATCH 01/41] Upgrade to OrientDB v2.2.0 --- pom.xml | 2 +- .../core/AbstractOrientOperations.java | 1137 ++++++++--------- .../orient/commons/core/OrientOperations.java | 247 ++-- .../OrientDocumentDatabaseFactory.java | 3 +- 4 files changed, 679 insertions(+), 710 deletions(-) diff --git a/pom.xml b/pom.xml index bd6f936..130bf1e 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 1.7.13 1.1.3 - 2.1.8 + 2.2.0 1.8.7 4.2.4.RELEASE 1.11.2.RELEASE diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java index d7da32b..6863ed3 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java @@ -1,12 +1,10 @@ package org.springframework.data.orient.commons.core; -import com.orientechnologies.common.exception.OException; import com.orientechnologies.orient.core.cache.OLocalRecordCache; import com.orientechnologies.orient.core.command.OCommandOutputListener; import com.orientechnologies.orient.core.command.OCommandRequest; import com.orientechnologies.orient.core.db.ODatabase; import com.orientechnologies.orient.core.db.ODatabaseListener; -import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.dictionary.ODictionary; import com.orientechnologies.orient.core.exception.OTransactionException; import com.orientechnologies.orient.core.hook.ORecordHook; @@ -16,7 +14,6 @@ import com.orientechnologies.orient.core.metadata.OMetadata; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.security.OSecurityUser; -import com.orientechnologies.orient.core.metadata.security.OUser; import com.orientechnologies.orient.core.query.OQuery; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.sql.OCommandSQL; @@ -26,7 +23,6 @@ import com.orientechnologies.orient.core.storage.ORecordMetadata; import com.orientechnologies.orient.core.storage.OStorage; import com.orientechnologies.orient.core.tx.OTransaction; -import com.orientechnologies.orient.core.version.ORecordVersion; import org.springframework.data.orient.commons.repository.DetachMode; import java.io.IOException; @@ -36,584 +32,563 @@ import java.util.concurrent.Callable; public abstract class AbstractOrientOperations implements OrientOperations { - //private static final Logger logger = LoggerFactory.getLogger(AbstractOrientOperations.class); - - protected final OrientDatabaseFactory dbf; - - protected Set defaultClusters; - - protected AbstractOrientOperations(OrientDatabaseFactory dbf) { - this.dbf = dbf; - } - - @Override - public String getName() { - return dbf.db().getName(); - } - - @Override - public String getURL() { - return dbf.db().getURL(); - } - - @Override - public ODatabase database() { - return dbf.db(); - } - - @Override - public Object setProperty(String name, Object value) { - return dbf.db().setProperty(name, value); - } - - @Override - public Object getProperty(String name) { - return dbf.db().getProperty(name); - } - - @Override - public Iterator> getProperties() { - return dbf.db().getProperties(); - } - - @Override - public Object get(ODatabase.ATTRIBUTES attribute) { - return dbf.db().get(attribute); - } - - @Override - public > DB set(ODatabase.ATTRIBUTES attribute, Object value) { - return dbf.db().set(attribute, value); - } - - @Override - public void registerListener(ODatabaseListener listener) { - dbf.db().registerListener(listener); - } - - @Override - public void unregisterListener(ODatabaseListener listener) { - dbf.db().unregisterListener(listener); - } - - @Override - public Map getHooks() { - return dbf.db().getHooks(); - } - - @Override - public > DB registerHook(ORecordHook hook) { - return dbf.db().registerHook(hook); - } - - @Override - public > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position) { - return dbf.db().registerHook(hook, position); - } - - @Override - public > DB unregisterHook(ORecordHook hook) { - return dbf.db().unregisterHook(hook); - } - - @Override - public ORecordHook.RESULT callbackHooks(ORecordHook.TYPE type, OIdentifiable id) { - return dbf.db().callbackHooks(type, id); - } - - @Override - public void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, int compressionLevel, int bufferSize) throws IOException { - dbf.db().backup(out, options, callable, listener, compressionLevel, bufferSize); - } - - @Override - public void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) throws IOException { - dbf.db().restore(in, options, callable, listener); - } - - @Override - public String getType() { - return dbf.db().getType(); - } - - @Override - public long getSize() { - return dbf.db().getSize(); - } - - @Override - public void freeze(boolean throwException) { - dbf.db().freeze(throwException); - } - - @Override - public void freeze() { - dbf.db().freeze(); - } - - @Override - public void release() { - dbf.db().release(); - } - - @Override - public OMetadata getMetadata() { - return dbf.db().getMetadata(); - } - - @Override - public ORecordMetadata getRecordMetadata(ORID rid) { - return dbf.db().getRecordMetadata(rid); - } - - - @Override - public ODictionary getDictionary() { - return dbf.db().getDictionary(); - } - - @Override - public boolean declareIntent(OIntent intent) { - return dbf.db().declareIntent(intent); - } - - @Override - public boolean isMVCC() { - return dbf.db().isMVCC(); - } - - @Override - public > DB setMVCC(boolean mvcc) { - return dbf.db().setMVCC(mvcc); - } - - @Override - public boolean isClosed() { - return dbf.db().isClosed(); - } - - @Override - public boolean isDefault(String clusterName) { - loadDefaultClusters(); - return defaultClusters.contains(clusterName); - } - - private void loadDefaultClusters() { + // private static final Logger logger = LoggerFactory.getLogger(AbstractOrientOperations.class); + + protected final OrientDatabaseFactory dbf; + + protected Set defaultClusters; + + protected AbstractOrientOperations(OrientDatabaseFactory dbf) { + this.dbf = dbf; + } + + @Override + public String getName() { + return dbf.db().getName(); + } + + @Override + public String getURL() { + return dbf.db().getURL(); + } + + @Override + public ODatabase database() { + return dbf.db(); + } + + @Override + public Object setProperty(String name, Object value) { + return dbf.db().setProperty(name, value); + } + + @Override + public Object getProperty(String name) { + return dbf.db().getProperty(name); + } + + @Override + public Iterator> getProperties() { + return dbf.db().getProperties(); + } + + @Override + public Object get(ODatabase.ATTRIBUTES attribute) { + return dbf.db().get(attribute); + } + + @Override + public > DB set(ODatabase.ATTRIBUTES attribute, Object value) { + return dbf.db().set(attribute, value); + } + + @Override + public void registerListener(ODatabaseListener listener) { + dbf.db().registerListener(listener); + } + + @Override + public void unregisterListener(ODatabaseListener listener) { + dbf.db().unregisterListener(listener); + } + + @Override + public Map getHooks() { + return dbf.db().getHooks(); + } + + @Override + public > DB registerHook(ORecordHook hook) { + return dbf.db().registerHook(hook); + } + + @Override + public > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position) { + return dbf.db().registerHook(hook, position); + } + + @Override + public > DB unregisterHook(ORecordHook hook) { + return dbf.db().unregisterHook(hook); + } + + @Override + public void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, + int compressionLevel, int bufferSize) throws IOException { + dbf.db().backup(out, options, callable, listener, compressionLevel, bufferSize); + } + + @Override + public void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) + throws IOException { + dbf.db().restore(in, options, callable, listener); + } + + @Override + public String getType() { + return dbf.db().getType(); + } + + @Override + public long getSize() { + return dbf.db().getSize(); + } + + @Override + public void freeze(boolean throwException) { + dbf.db().freeze(throwException); + } + + @Override + public void freeze() { + dbf.db().freeze(); + } + + @Override + public void release() { + dbf.db().release(); + } + + @Override + public OMetadata getMetadata() { + return dbf.db().getMetadata(); + } + + @Override + public ORecordMetadata getRecordMetadata(ORID rid) { + return dbf.db().getRecordMetadata(rid); + } + + @Override + public ODictionary getDictionary() { + return dbf.db().getDictionary(); + } + + @Override + public boolean declareIntent(OIntent intent) { + return dbf.db().declareIntent(intent); + } + + @Override + public boolean isMVCC() { + return dbf.db().isMVCC(); + } + + @Override + public > DB setMVCC(boolean mvcc) { + return dbf.db().setMVCC(mvcc); + } + + @Override + public boolean isClosed() { + return dbf.db().isClosed(); + } + + @Override + public boolean isDefault(String clusterName) { + loadDefaultClusters(); + return defaultClusters.contains(clusterName); + } + + private void loadDefaultClusters() { + if (defaultClusters == null) { + synchronized (this) { if (defaultClusters == null) { - synchronized (this) { - if (defaultClusters == null) { - defaultClusters = new HashSet<>(); - for (OClass oClass : dbf.db().getMetadata().getSchema().getClasses()) { - String defaultCluster = getClusterNameById(oClass.getDefaultClusterId()); - defaultClusters.add(defaultCluster); - } - } - } - } - } - - @Override - public void reload() { - dbf.db().reload(); - } - - @Override - public T reload(T entity, String fetchPlan, boolean ignoreCache) { - return dbf.db().reload(entity, fetchPlan, ignoreCache); - } - - @Override - public ODatabase.STATUS getStatus() { - return dbf.db().getStatus(); - } - - @Override - public > DB setStatus(ODatabase.STATUS status) { - return dbf.db().setStatus(status); - } - - @Override - public OTransaction getTransaction() { - return dbf.db().getTransaction(); - } - - @Override - public ODatabase begin() { - return dbf.db().begin(); - } - - @Override - public ODatabase begin(OTransaction.TXTYPE type) { - return dbf.db().begin(type); - } - - @Override - public ODatabase begin(OTransaction tx) { - return dbf.db().begin(tx); - } - - @Override - public ODatabase commit() { - return dbf.db().commit(); - } - - @Override - public ODatabase commit(boolean force) throws OTransactionException { - return dbf.db().commit(force); - } - - @Override - public ODatabase rollback() { - return dbf.db().rollback(); - } - - @Override - public ODatabase rollback(boolean force) throws OTransactionException { - return dbf.db().rollback(force); - } - - @Override - public OLocalRecordCache getLevel2Cache() { - return dbf.db().getLocalCache(); - } - - @Override - public T newInstance() { - return dbf.db().newInstance(); - } - - @Override - public T load(ORID recordId) { - return dbf.db().load(recordId); - } - - @Override - public T load(String recordId) { - return load(new ORecordId(recordId)); - } - - public T load(T entity) { - return dbf.db().load(entity); - } - - @Override - public T load(T entity, String fetchPlan) { - return dbf.db().load(entity, fetchPlan); - } - - @Override - public T load(T entity, String fetchPlan, boolean ignoreCache) { - return dbf.db().load(entity, fetchPlan, ignoreCache); - } - - @Override - public T load(ORID recordId, String fetchPlan) { - return dbf.db().load(recordId, fetchPlan); - } - - @Override - public T load(ORID recordId, String fetchPlan, boolean ignoreCache) { - return dbf.db().load(recordId, fetchPlan, ignoreCache); - } - - @Override - public T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy) { - return dbf.db().load(entity, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); - } - - @Override - public T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy) { - return dbf.db().load(recordId, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); - } - - @Override - public S save(S entity) { - return dbf.db().save(entity); - } - - @Override - public S save(S entity, String cluster) { - return dbf.db().save(entity, cluster); - } - - @Override - public S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback) { - return dbf.db().save(entity, mode, forceCreate, recordCallback, recordUpdatedCallback); - } - - @Override - public long countClass(Class clazz) { - return count(new OSQLSynchQuery("select count(*) from " + clazz.getSimpleName())); - } - - @Override - public long countClass(String className) { - return count(new OSQLSynchQuery("select count(*) from " + className)); - } - - @Override - public long count(OSQLQuery query, Object... args) { - return ((ODocument) dbf.db().query(query, args).get(0)).field("count"); - } - - @Override - public long countClusterElements(String clusterName) { - return dbf.db().countClusterElements(clusterName); - } - - @Override - public long countClusterElements(int clusterId) { - return dbf.db().countClusterElements(clusterId); - } - - @Override - public long countClusterElements(int[] clusterIds) { - return dbf.db().countClusterElements(clusterIds); - } - - @Override - public long countClusterElements(int iClusterId, boolean countTombstones) { - return dbf.db().countClusterElements(iClusterId, countTombstones); - } - - @Override - public long countClusterElements(int[] iClusterIds, boolean countTombstones) { - return dbf.db().countClusterElements(iClusterIds, countTombstones); - } - - @Override - public int getClusters() { - return dbf.db().getClusters(); - } - - @Override - public boolean existsCluster(String clusterName) { - return dbf.db().existsCluster(clusterName); - } - - @Override - public Collection getClusterNames() { - return dbf.db().getClusterNames(); - } - - @Override - public int getClusterIdByName(String clusterName, Class clazz) { - OClass oClass = dbf.db().getMetadata().getSchema().getClass(clazz); - for(int clusterId : oClass.getClusterIds()){ - if(getClusterNameById(clusterId).equals(clusterName)){ - return clusterId; - } - } - - throw new OException("Cluster " + clusterName + " not found"); - } - - @Override - public String getClusterNameByRid(String rid) { - return getClusterNameById(new ORecordId(rid).getClusterId()); - } - - @Override - public List getClusterNamesByClass(Class clazz, boolean showDefault) { - int[] clusterIds = dbf.db().getMetadata().getSchema().getClass(clazz).getClusterIds(); - int defaultCluster = getDefaultClusterId(clazz); - - List clusters = new ArrayList<>(clusterIds.length); - for (int clusterId : clusterIds) { - if (showDefault || clusterId != defaultCluster) { - clusters.add(getClusterNameById(clusterId)); - } - } - - return clusters; - } - - @Override - public int getDefaultClusterId(Class domainClass) { - return dbf.db().getMetadata().getSchema().getClass(domainClass).getDefaultClusterId(); - } - - @Override - public long getClusterRecordSizeById(int clusterId) { - return dbf.db().getClusterRecordSizeById(clusterId); - } - - @Override - public long getClusterRecordSizeByName(String clusterName) { - return dbf.db().getClusterRecordSizeByName(clusterName); - } - - @Override - public int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params) { - return dbf.db().addCluster(type, clusterName, location, dataSegmentName, params); - } - - @Override - public int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, Object... params) { - return dbf.db().addCluster(type, clusterName, requestedId, location, dataSegmentName, params); - } - - @Override - public int addCluster(String clusterName, Object... params) { - return dbf.db().addCluster(clusterName, params); - } - - @Override - public int addCluster(String clusterName) { - return dbf.db().addCluster(clusterName); - } - - @Override - public void freezeCluster(int iClusterId, boolean throwException) { - dbf.db().freezeCluster(iClusterId, throwException); - } - - @Override - public void freezeCluster(int iClusterId) { - dbf.db().freezeCluster(iClusterId); - } - - @Override - public void releaseCluster(int iClusterId) { - dbf.db().releaseCluster(iClusterId); - } - - @Override - public ODatabase delete(ORID recordId) { - return dbf.db().delete(recordId); - } - - @Override - public ODatabase delete(T entity) { - return dbf.db().delete(entity); - } - - @Override - public ODatabase delete(ORID rid, ORecordVersion version) { - return dbf.db().delete(rid, version); - } - - @Override - public int getDefaultClusterId() { - return dbf.db().getDefaultClusterId(); - } - - @Override - public String getClusterNameById(int clusterId) { - return dbf.db().getClusterNameById(clusterId); - } - - @Override - public int getClusterIdByName(String clusterName) { - return dbf.db().getClusterIdByName(clusterName); - } - - @Override - public boolean existsClass(Class clazz) { - return existsClass(clazz.getSimpleName()); - } - - @Override - public boolean existsClass(String className) { - return dbf.db().getMetadata().getSchema().existsClass(className); - } - - @Override - public OSecurityUser getUser() { - return dbf.db().getUser(); - } - - @Override - public void setUser(OUser user) { - dbf.db().setUser(user); - } - - @Override - @SuppressWarnings("unchecked") - public > RET detach(RET entities) { - List result = new ArrayList<>(entities.size()); - - for (Object entity : entities) { - result.add(detach(entity)); - } - - return (RET)result; - } - - @Override - @SuppressWarnings("unchecked") - public > RET detachAll(RET entities) { - List result = new ArrayList<>(entities.size()); - - for (Object entity : entities) { - result.add(detachAll(entity)); - } - - return (RET)result; - } - - @Override - public > RET query(OQuery query, Object... args) { - return dbf.db().query(query, args); - } - - @Override - public > RET query(OQuery query, DetachMode detachMode, Object... args) { - RET result = query(query, args); - - switch (detachMode) { - case ENTITY: - return detach(result); - case ALL: - return detachAll(result); - case NONE: - } - - return result; - } - - @Override - @SuppressWarnings("unchecked") - public RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args) { - RET result = queryForObject(query, args); - - switch (detachMode) { - case ENTITY: - return detach(result); - case ALL: - return detachAll(result); - case NONE: + defaultClusters = new HashSet<>(); + for (OClass oClass : dbf.db().getMetadata().getSchema().getClasses()) { + String defaultCluster = getClusterNameById(oClass.getDefaultClusterId()); + defaultClusters.add(defaultCluster); + } } + } + } + } + + @Override + public void reload() { + dbf.db().reload(); + } + + @Override + public T reload(T entity, String fetchPlan, boolean ignoreCache) { + return dbf.db().reload(entity, fetchPlan, ignoreCache); + } + + @Override + public ODatabase.STATUS getStatus() { + return dbf.db().getStatus(); + } + + @Override + public > DB setStatus(ODatabase.STATUS status) { + return dbf.db().setStatus(status); + } + + @Override + public OTransaction getTransaction() { + return dbf.db().getTransaction(); + } + + @Override + public ODatabase begin() { + return dbf.db().begin(); + } + + @Override + public ODatabase begin(OTransaction.TXTYPE type) { + return dbf.db().begin(type); + } + + @Override + public ODatabase begin(OTransaction tx) { + return dbf.db().begin(tx); + } + + @Override + public ODatabase commit() { + return dbf.db().commit(); + } + + @Override + public ODatabase commit(boolean force) throws OTransactionException { + return dbf.db().commit(force); + } + + @Override + public ODatabase rollback() { + return dbf.db().rollback(); + } + + @Override + public ODatabase rollback(boolean force) throws OTransactionException { + return dbf.db().rollback(force); + } + + @Override + public OLocalRecordCache getLevel2Cache() { + return dbf.db().getLocalCache(); + } + + @Override + public T newInstance() { + return dbf.db().newInstance(); + } + + @Override + public T load(ORID recordId) { + return dbf.db().load(recordId); + } + + @Override + public T load(String recordId) { + return load(new ORecordId(recordId)); + } + + public T load(T entity) { + return dbf.db().load(entity); + } + + @Override + public T load(T entity, String fetchPlan) { + return dbf.db().load(entity, fetchPlan); + } + + @Override + public T load(T entity, String fetchPlan, boolean ignoreCache) { + return dbf.db().load(entity, fetchPlan, ignoreCache); + } + + @Override + public T load(ORID recordId, String fetchPlan) { + return dbf.db().load(recordId, fetchPlan); + } + + @Override + public T load(ORID recordId, String fetchPlan, boolean ignoreCache) { + return dbf.db().load(recordId, fetchPlan, ignoreCache); + } + + @Override + public T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy) { + return dbf.db().load(entity, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); + } + + @Override + public T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, + OStorage.LOCKING_STRATEGY lockingStrategy) { + return dbf.db().load(recordId, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); + } + + @Override + public S save(S entity) { + return dbf.db().save(entity); + } + + @Override + public S save(S entity, String cluster) { + return dbf.db().save(entity, cluster); + } + + @Override + public S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, + ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback) { + return dbf.db().save(entity, mode, forceCreate, recordCallback, recordUpdatedCallback); + } + + @Override + public long countClass(Class clazz) { + return count(new OSQLSynchQuery("select count(*) from " + clazz.getSimpleName())); + } + + @Override + public long countClass(String className) { + return count(new OSQLSynchQuery("select count(*) from " + className)); + } + + @Override + public long count(OSQLQuery query, Object... args) { + return ((ODocument) dbf.db().query(query, args).get(0)).field("count"); + } + + @Override + public long countClusterElements(String clusterName) { + return dbf.db().countClusterElements(clusterName); + } + + @Override + public long countClusterElements(int clusterId) { + return dbf.db().countClusterElements(clusterId); + } + + @Override + public long countClusterElements(int[] clusterIds) { + return dbf.db().countClusterElements(clusterIds); + } + + @Override + public long countClusterElements(int iClusterId, boolean countTombstones) { + return dbf.db().countClusterElements(iClusterId, countTombstones); + } + + @Override + public long countClusterElements(int[] iClusterIds, boolean countTombstones) { + return dbf.db().countClusterElements(iClusterIds, countTombstones); + } + + @Override + public int getClusters() { + return dbf.db().getClusters(); + } + + @Override + public boolean existsCluster(String clusterName) { + return dbf.db().existsCluster(clusterName); + } + + @Override + public Collection getClusterNames() { + return dbf.db().getClusterNames(); + } + + @Override + public int getClusterIdByName(String clusterName, Class clazz) { + OClass oClass = dbf.db().getMetadata().getSchema().getClass(clazz); + for (int clusterId : oClass.getClusterIds()) { + if (getClusterNameById(clusterId).equals(clusterName)) { + return clusterId; + } + } + + throw new IllegalArgumentException("Cluster " + clusterName + " not found"); + } + + @Override + public String getClusterNameByRid(String rid) { + return getClusterNameById(new ORecordId(rid).getClusterId()); + } + + @Override + public List getClusterNamesByClass(Class clazz, boolean showDefault) { + int[] clusterIds = dbf.db().getMetadata().getSchema().getClass(clazz).getClusterIds(); + int defaultCluster = getDefaultClusterId(clazz); + + List clusters = new ArrayList<>(clusterIds.length); + for (int clusterId : clusterIds) { + if (showDefault || clusterId != defaultCluster) { + clusters.add(getClusterNameById(clusterId)); + } + } + + return clusters; + } + + @Override + public int getDefaultClusterId(Class domainClass) { + return dbf.db().getMetadata().getSchema().getClass(domainClass).getDefaultClusterId(); + } + + @Override + public long getClusterRecordSizeById(int clusterId) { + return dbf.db().getClusterRecordSizeById(clusterId); + } + + @Override + public long getClusterRecordSizeByName(String clusterName) { + return dbf.db().getClusterRecordSizeByName(clusterName); + } + + @Override + public int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params) { + return dbf.db().addCluster(type, clusterName, location, dataSegmentName, params); + } + + @Override + public int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, + Object... params) { + return dbf.db().addCluster(type, clusterName, requestedId, location, dataSegmentName, params); + } + + @Override + public int addCluster(String clusterName, Object... params) { + return dbf.db().addCluster(clusterName, params); + } + + @Override + public int addCluster(String clusterName) { + return dbf.db().addCluster(clusterName); + } + + @Override + public ODatabase delete(ORID recordId) { + return dbf.db().delete(recordId); + } + + @Override + public ODatabase delete(T entity) { + return dbf.db().delete(entity); + } + + @Override + public ODatabase delete(ORID rid, int version) { + return dbf.db().delete(rid, version); + } + + @Override + public int getDefaultClusterId() { + return dbf.db().getDefaultClusterId(); + } + + @Override + public String getClusterNameById(int clusterId) { + return dbf.db().getClusterNameById(clusterId); + } + + @Override + public int getClusterIdByName(String clusterName) { + return dbf.db().getClusterIdByName(clusterName); + } + + @Override + public boolean existsClass(Class clazz) { + return existsClass(clazz.getSimpleName()); + } + + @Override + public boolean existsClass(String className) { + return dbf.db().getMetadata().getSchema().existsClass(className); + } + + @Override + public OSecurityUser getUser() { + return dbf.db().getUser(); + } + + @Override + @SuppressWarnings("unchecked") + public > RET detach(RET entities) { + List result = new ArrayList<>(entities.size()); + + for (Object entity : entities) { + result.add(detach(entity)); + } + + return (RET) result; + } + + @Override + @SuppressWarnings("unchecked") + public > RET detachAll(RET entities) { + List result = new ArrayList<>(entities.size()); + + for (Object entity : entities) { + result.add(detachAll(entity)); + } + + return (RET) result; + } + + @Override + public > RET query(OQuery query, Object... args) { + return dbf.db().query(query, args); + } + + @Override + public > RET query(OQuery query, DetachMode detachMode, Object... args) { + RET result = query(query, args); + + switch (detachMode) { + case ENTITY: + return detach(result); + case ALL: + return detachAll(result); + case NONE: + } + + return result; + } + + @Override + @SuppressWarnings("unchecked") + public RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args) { + RET result = queryForObject(query, args); + + switch (detachMode) { + case ENTITY: + return detach(result); + case ALL: + return detachAll(result); + case NONE: + } + + return result; + } + + @Override + @SuppressWarnings("unchecked") + public RET queryForObject(OSQLQuery query, Object... args) { + return (RET) query(query, args).get(0); + } + + @Override + public RET command(OCommandRequest command) { + return dbf.db().command(command); + } + + @Override + public RET command(OCommandSQL command, Object... args) { + return dbf.db().command(command).execute(args); + } + + @Override + public RET command(String sql, Object... args) { + return dbf.db().command(new OCommandSQL(sql)).execute(args); + } + + public boolean equals(Object other) { + return dbf.db().equals(other); + } - return result; - } - - @Override - @SuppressWarnings("unchecked") - public RET queryForObject(OSQLQuery query, Object... args) { - return (RET)query(query, args).get(0); - } - - @Override - public RET command(OCommandRequest command) { - return dbf.db().command(command); - } - - @Override - public RET command(OCommandSQL command, Object... args) { - return dbf.db().command(command).execute(args); - } - - @Override - public RET command(String sql, Object... args) { - return dbf.db().command(new OCommandSQL(sql)).execute(args); - } - - public boolean equals(Object other) { - return dbf.db().equals(other); - } - - public String toString() { - return dbf.db().toString(); - } + public String toString() { + return dbf.db().toString(); + } } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java index 75d1c98..0722ec0 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java @@ -13,7 +13,6 @@ import com.orientechnologies.orient.core.intent.OIntent; import com.orientechnologies.orient.core.metadata.OMetadata; import com.orientechnologies.orient.core.metadata.security.OSecurityUser; -import com.orientechnologies.orient.core.metadata.security.OUser; import com.orientechnologies.orient.core.query.OQuery; import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.query.OSQLQuery; @@ -21,54 +20,56 @@ import com.orientechnologies.orient.core.storage.ORecordMetadata; import com.orientechnologies.orient.core.storage.OStorage; import com.orientechnologies.orient.core.tx.OTransaction; -import com.orientechnologies.orient.core.version.ORecordVersion; import org.springframework.data.orient.commons.repository.DetachMode; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.*; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; public interface OrientOperations { - String getName(); + String getName(); - String getURL(); + String getURL(); - ODatabase database(); + ODatabase database(); - Object setProperty(String name, Object value); + Object setProperty(String name, Object value); - Object getProperty(String name); + Object getProperty(String name); - Iterator> getProperties(); + Iterator> getProperties(); - Object get(ODatabase.ATTRIBUTES attribute); + Object get(ODatabase.ATTRIBUTES attribute); - > DB set(ODatabase.ATTRIBUTES attribute, Object value); + > DB set(ODatabase.ATTRIBUTES attribute, Object value); - public void registerListener(ODatabaseListener listener); + public void registerListener(ODatabaseListener listener); - public void unregisterListener(ODatabaseListener listener); + public void unregisterListener(ODatabaseListener listener); - Map getHooks(); + Map getHooks(); - > DB registerHook(ORecordHook hook); + > DB registerHook(ORecordHook hook); - > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position); + > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position); - > DB unregisterHook(ORecordHook hook); + > DB unregisterHook(ORecordHook hook); - ORecordHook.RESULT callbackHooks(ORecordHook.TYPE type, OIdentifiable id); + void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, + int compressionLevel, int bufferSize) throws IOException; - void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, int compressionLevel, int bufferSize) throws IOException; + void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) + throws IOException; - void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) throws IOException; + String getType(); - String getType(); - - long getSize(); + long getSize(); void freeze(boolean throwException); @@ -78,181 +79,175 @@ public interface OrientOperations { OMetadata getMetadata(); - ORecordMetadata getRecordMetadata(ORID rid); - - ODictionary getDictionary(); + ORecordMetadata getRecordMetadata(ORID rid); - boolean declareIntent(OIntent intent); + ODictionary getDictionary(); + boolean declareIntent(OIntent intent); - public boolean isMVCC(); + public boolean isMVCC(); - public > DB setMVCC(boolean mvcc); + public > DB setMVCC(boolean mvcc); - boolean isClosed(); + boolean isClosed(); - void reload(); + void reload(); - T reload(T entity, String fetchPlan, boolean ignoreCache); + T reload(T entity, String fetchPlan, boolean ignoreCache); - ODatabase.STATUS getStatus(); + ODatabase.STATUS getStatus(); - > DB setStatus(ODatabase.STATUS status); + > DB setStatus(ODatabase.STATUS status); - OTransaction getTransaction(); + OTransaction getTransaction(); - ODatabase begin(); + ODatabase begin(); - ODatabase begin(OTransaction.TXTYPE type); + ODatabase begin(OTransaction.TXTYPE type); - ODatabase begin(OTransaction tx); + ODatabase begin(OTransaction tx); - ODatabase commit(); + ODatabase commit(); - ODatabase commit(boolean force) throws OTransactionException; + ODatabase commit(boolean force) throws OTransactionException; - ODatabase rollback(); + ODatabase rollback(); - ODatabase rollback(boolean force) throws OTransactionException; + ODatabase rollback(boolean force) throws OTransactionException; - OLocalRecordCache getLevel2Cache(); + OLocalRecordCache getLevel2Cache(); - T newInstance(); - - T load(ORID recordId); - - T load(String recordId); + T newInstance(); - T load(T entity); + T load(ORID recordId); - T load(T entity, String fetchPlan); + T load(String recordId); - T load(T entity, String fetchPlan, boolean ignoreCache); + T load(T entity); - T load(ORID recordId, String fetchPlan); + T load(T entity, String fetchPlan); - T load(ORID recordId, String fetchPlan, boolean ignoreCache); + T load(T entity, String fetchPlan, boolean ignoreCache); - T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); + T load(ORID recordId, String fetchPlan); - T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); + T load(ORID recordId, String fetchPlan, boolean ignoreCache); - S save(S entity); - - S save(S entity, String cluster); + T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); - S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback); + T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); - long countClass(String className); + S save(S entity); - long countClass(Class clazz); + S save(S entity, String cluster); - long count(OSQLQuery query, Object... args); + S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, + ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback); - long countClusterElements(String clusterName); + long countClass(String className); - long countClusterElements(int clusterId); + long countClass(Class clazz); - long countClusterElements(int[] clusterIds); + long count(OSQLQuery query, Object... args); - long countClusterElements(int iClusterId, boolean countTombstones); + long countClusterElements(String clusterName); - long countClusterElements(int[] iClusterIds, boolean countTombstones); + long countClusterElements(int clusterId); - int getClusters(); + long countClusterElements(int[] clusterIds); - boolean existsCluster(String iClusterName); + long countClusterElements(int iClusterId, boolean countTombstones); - Collection getClusterNames(); + long countClusterElements(int[] iClusterIds, boolean countTombstones); - ODatabase delete(ORID recordId); + int getClusters(); - ODatabase delete(T entity); + boolean existsCluster(String iClusterName); - ODatabase delete(ORID rid, ORecordVersion version); + Collection getClusterNames(); - int getDefaultClusterId(); + ODatabase delete(ORID recordId); - int getDefaultClusterId(Class domainClass); + ODatabase delete(T entity); - String getClusterNameById(int clusterId); + ODatabase delete(ORID rid, int version); - int getClusterIdByName(String clusterName); + int getDefaultClusterId(); - int getClusterIdByName(String clusterName, Class clazz); + int getDefaultClusterId(Class domainClass); - String getClusterNameByRid(String rid); + String getClusterNameById(int clusterId); - List getClusterNamesByClass(Class clazz, boolean includeDefault); + int getClusterIdByName(String clusterName); - long getClusterRecordSizeById(int clusterId); + int getClusterIdByName(String clusterName, Class clazz); - long getClusterRecordSizeByName(String clusterName); + String getClusterNameByRid(String rid); - int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params); + List getClusterNamesByClass(Class clazz, boolean includeDefault); - int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, Object... params); + long getClusterRecordSizeById(int clusterId); - int addCluster(String clusterName, Object... params); + long getClusterRecordSizeByName(String clusterName); - int addCluster(String clusterName); + int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params); - public void freezeCluster(int iClusterId, boolean throwException); + int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, Object... params); - public void freezeCluster(int iClusterId); + int addCluster(String clusterName, Object... params); - public void releaseCluster(int iClusterId); + int addCluster(String clusterName); - boolean isDefault(String clusterName); + boolean isDefault(String clusterName); - /** - * Is Class registered in OrientDb - * - * @param clazz class to check - * @return Is Class registered in OrientDb - */ - boolean existsClass(Class clazz); + /** + * Is Class registered in OrientDb + * + * @param clazz + * class to check + * @return Is Class registered in OrientDb + */ + boolean existsClass(Class clazz); - /** - * Is Class registered in OrientDb - * - * @param className simple class name (clazz.getSimpleName()) - * @return Is Class registered in OrientDb - */ - boolean existsClass(String className); + /** + * Is Class registered in OrientDb + * + * @param className + * simple class name (clazz.getSimpleName()) + * @return Is Class registered in OrientDb + */ + boolean existsClass(String className); - /** - * Find field annotated with {@link com.orientechnologies.orient.core.annotation.OId} - * in entity and return it's value. - * - * @param entity Orient Entity - * @return orient row ID or null if it is to found - */ - String getRid(T entity); + /** + * Find field annotated with {@link com.orientechnologies.orient.core.annotation.OId} in entity and return it's value. + * + * @param entity + * Orient Entity + * @return orient row ID or null if it is to found + */ + String getRid(T entity); - OSecurityUser getUser(); + OSecurityUser getUser(); - void setUser(OUser user); + > RET detach(RET entities); - > RET detach(RET entities); + > RET detachAll(RET list); - > RET detachAll(RET list); + RET detach(RET entity); - RET detach(RET entity); + RET detachAll(RET entity); - RET detachAll(RET entity); + > RET query(OQuery query, Object... args); - > RET query(OQuery query, Object... args); + > RET query(OQuery query, DetachMode detachMode, Object... args); - > RET query(OQuery query, DetachMode detachMode, Object... args); + RET queryForObject(OSQLQuery query, Object... args); - RET queryForObject(OSQLQuery query, Object... args); + RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args); - RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args); + RET command(OCommandRequest command); - RET command(OCommandRequest command); + RET command(OCommandSQL command, Object... args); - RET command(OCommandSQL command, Object... args); - - RET command(String sql, Object... args); + RET command(String sql, Object... args); } diff --git a/spring-data-orientdb-document/src/main/java/org/springframework/data/orient/document/OrientDocumentDatabaseFactory.java b/spring-data-orientdb-document/src/main/java/org/springframework/data/orient/document/OrientDocumentDatabaseFactory.java index f1a767e..7806432 100644 --- a/spring-data-orientdb-document/src/main/java/org/springframework/data/orient/document/OrientDocumentDatabaseFactory.java +++ b/spring-data-orientdb-document/src/main/java/org/springframework/data/orient/document/OrientDocumentDatabaseFactory.java @@ -3,7 +3,6 @@ import com.orientechnologies.orient.core.db.OPartitionedDatabasePool; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.record.ORecord; -import com.orientechnologies.orient.core.record.impl.ODocument; import org.springframework.data.orient.commons.core.AbstractOrientDatabaseFactory; /** @@ -21,7 +20,7 @@ public class OrientDocumentDatabaseFactory extends AbstractOrientDatabaseFactory @Override protected void createPool() { - pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword(), maxPoolSize); + pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword(), maxPoolSize, -1); } /* (non-Javadoc) From 6600914746f0d8c9efc10188e7289ef7f8b1cd5c Mon Sep 17 00:00:00 2001 From: lvca Date: Thu, 2 Jun 2016 13:25:03 +0200 Subject: [PATCH 02/41] Changed the groupId to be published as OrientDB. Bumped to version 0.11 --- pom.xml | 141 +++++++++++++----- spring-boot-orientdb-autoconfigure/pom.xml | 12 +- spring-data-orientdb-benchmarks/pom.xml | 4 +- spring-data-orientdb-commons/pom.xml | 4 +- spring-data-orientdb-document/pom.xml | 6 +- spring-data-orientdb-graph/pom.xml | 6 +- spring-data-orientdb-object/pom.xml | 6 +- .../spring-boot-orientdb-hello/pom.xml | 6 +- .../spring-boot-orientdb-shiro/pom.xml | 6 +- 9 files changed, 128 insertions(+), 63 deletions(-) diff --git a/pom.xml b/pom.xml index 130bf1e..e3d34af 100644 --- a/pom.xml +++ b/pom.xml @@ -18,14 +18,19 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 pom Spring Data OrientDB Spring Data OrientDB - http://www.orientechnologies.com + http://orientdb.com + 2015 + + OrientDB + http://orientdb.com + Apache 2 @@ -33,6 +38,13 @@ + + + google groups + http://groups.google.com/group/orient-database/topics + + + spring-data-orientdb-commons spring-data-orientdb-document @@ -44,6 +56,59 @@ spring-data-orientdb-samples/spring-boot-orientdb-shiro + + scm:git:git@github.com:orientechnologies/spring-data-orientdb.git + scm:git:git@github.com:orientechnologies/spring-data-orientdb.git + scm:git:git@github.com:orientechnologies/spring-data-orientdb.git + + + GitHub Issues + https://github.com/orientechnologies/spring-data-orientdb/issues + + + + jenkins + http://helios.orientdb.com/ + + + + + sonatype-nexus-staging + OrientDB Maven2 Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + sonatype-nexus-snapshots + OrientDB Maven2 Snapshot Repository + https://oss.sonatype.org/content/repositories/snapshots + false + + + + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + UTF-8 @@ -73,15 +138,17 @@ 4.12 6.8.21 2.4.0 + https://oss.sonatype.org/content/repositories/snapshots/ + l.garulli Luca Garulli - l.garulli@orientechnologies.com - Orientechnologies - http://www.orientechnologies.com + l.garulli@orientdb.com + OrientDB + http://orientdb.com architect developer @@ -127,32 +194,6 @@ - - scm:git:git@github.com:orientechnologies/spring-data-orientdb.git - scm:git:git@github.com:orientechnologies/spring-data-orientdb.git - scm:git:git@github.com:orientechnologies/spring-data-orientdb.git - - - GitHub Issues - https://github.com/orientechnologies/spring-data-orientdb/issues - - - jenkins - http://datastorm.com.ua/ - - - - sonatype-nexus-staging - OrientDB Maven2 Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - sonatype-nexus-snapshots - OrientDB Maven2 Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - - @@ -352,12 +393,6 @@ - - - spring-libs-snapshot - http://repo.spring.io/libs-snapshot - - spring-plugins-release @@ -699,4 +734,34 @@ + + + + release-sign-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + + diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 08fface..8554cab 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -5,13 +5,13 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../pom.xml - org.springframework.boot + com.orientechnologies spring-boot-orientdb-autoconfigure jar Spring Boot OrientDB @@ -30,17 +30,17 @@ - org.springframework.data + com.orientechnologies spring-data-orientdb-document ${project.version} - org.springframework.data + com.orientechnologies spring-data-orientdb-object ${project.version} - org.springframework.data + com.orientechnologies spring-data-orientdb-graph ${project.version} diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index ce73a55..728692e 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -5,9 +5,9 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 1cba99b..86d000e 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -5,9 +5,9 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 068b7b2..bf9d1c2 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -5,9 +5,9 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../pom.xml @@ -18,7 +18,7 @@ - org.springframework.data + com.orientechnologies spring-data-orientdb-commons ${project.version} diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index 0d35e93..b9a2b88 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -5,9 +5,9 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../pom.xml @@ -18,7 +18,7 @@ - org.springframework.data + com.orientechnologies spring-data-orientdb-commons ${project.version} diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index a1a619c..bb35520 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -5,9 +5,9 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../pom.xml @@ -18,7 +18,7 @@ - org.springframework.data + com.orientechnologies spring-data-orientdb-commons ${project.version} diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 1513211..b3af88c 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -5,13 +5,13 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../../pom.xml - org.springframework.boot.samples + com.orientechnologies.samples spring-boot-orientdb-hello jar Sample - Spring Boot OrientDB Hello diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 33a2870..445b7b4 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -5,13 +5,13 @@ 4.0.0 - org.springframework.data + com.orientechnologies spring-data-orientdb-parent - 0.10.0-SNAPSHOT + 0.11 ../../pom.xml - org.springframework.boot.samples + com.orientechnologies.samples spring-boot-orientdb-shiro jar Sample - Spring Boot OrientDB Shiro From 7a3dc5072b9d4e1f9bb995fa1bf8057534727053 Mon Sep 17 00:00:00 2001 From: lvca Date: Thu, 2 Jun 2016 13:35:16 +0200 Subject: [PATCH 03/41] Switched to v0.12-SNAPSHOT --- _base/script/upd_version.sh | 20 +++++++++++++++++++ pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- .../spring-boot-orientdb-hello/pom.xml | 2 +- .../spring-boot-orientdb-shiro/pom.xml | 2 +- 10 files changed, 29 insertions(+), 9 deletions(-) create mode 100755 _base/script/upd_version.sh diff --git a/_base/script/upd_version.sh b/_base/script/upd_version.sh new file mode 100755 index 0000000..6a37e66 --- /dev/null +++ b/_base/script/upd_version.sh @@ -0,0 +1,20 @@ +#!/bin/bash +if [ -z "$1" -o -z "$2" -o -z "$3" ] +then + echo "SYNTAX ERROR, USE: upd-version.sh " + exit +fi + +echo "Updating version from $2 to $3 in directory $1 and subfolders" + +TFILE="/tmp/out.tmp.$$" +for filename in $(grep -r "$2" --include "pom.xml" $1|cut -f 1 -d :) +do + if [ -f $filename -a -r $filename ]; then + #/bin/cp -f $filename ${filename}.old + sed "s/$2/$3/g" "$filename" > $TFILE && mv $TFILE "$filename" + else + echo "Error: Cannot read $filename" + fi +done +/bin/rm $TFILE 2>/dev/null diff --git a/pom.xml b/pom.xml index e3d34af..0fc1b4b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 8554cab..139c81d 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 728692e..477599e 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 86d000e..8b46cd3 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index bf9d1c2..d921e21 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index b9a2b88..ccc3d17 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index bb35520..37d3321 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index b3af88c..005ba3e 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 445b7b4..7865ffc 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.11 + 0.12-SNAPSHOT ../../pom.xml From ce12c50fc22a9706d4539345c3dffa9d5b8976a8 Mon Sep 17 00:00:00 2001 From: lvca Date: Thu, 2 Jun 2016 14:07:19 +0200 Subject: [PATCH 04/41] Updated dependency --- .../spring-boot-orientdb-hello/pom.xml | 10 ++++++++++ .../spring-boot-orientdb-shiro/pom.xml | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 005ba3e..c15c875 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -35,6 +35,16 @@ spring-boot-starter-test test + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + 1.0.1.Final + + + com.orientechnologies + spring-data-orientdb-object + 0.12-SNAPSHOT + diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 7865ffc..a37e841 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -73,6 +73,20 @@ spring-boot-starter-test test + + org.springframework + spring-tx + + + com.orientechnologies + spring-data-orientdb-commons + 0.12-SNAPSHOT + + + com.orientechnologies + spring-data-orientdb-object + 0.12-SNAPSHOT + From c1cf03ace874fdb99b36456f5644b8063779b531 Mon Sep 17 00:00:00 2001 From: Luca Garulli Date: Thu, 2 Jun 2016 14:17:37 +0200 Subject: [PATCH 05/41] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 6dbfcd2..3da2808 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,13 @@ The SpringData OrientDB project will implement easy to use APIs for using Orient The document module is based on the [Spring Data MongoDB](http://projects.spring.io/spring-data-mongodb/) project. [![Build Status](https://drone.io/github.com/vidakovic/spring-data-orientdb/status.png)](https://drone.io/github.com/vidakovic/spring-data-orientdb/latest) + +To include OrientDB Spring Data in your Java project via Maven use: + +```xml + + com.orientechnologies + spring-data-orientdb-object + 0.11 + +``` From 7990781fa552851dc01318e20fe05ac6493bf143 Mon Sep 17 00:00:00 2001 From: Luca Garulli Date: Thu, 2 Jun 2016 14:18:50 +0200 Subject: [PATCH 06/41] Update README.md --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3da2808..2d41422 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,27 @@ The document module is based on the [Spring Data MongoDB](http://projects.spring [![Build Status](https://drone.io/github.com/vidakovic/spring-data-orientdb/status.png)](https://drone.io/github.com/vidakovic/spring-data-orientdb/latest) -To include OrientDB Spring Data in your Java project via Maven use: +To include OrientDB Spring Data in your Java project via Maven, put one of the snippets below in your pom.xml +### Graph API +```xml + + com.orientechnologies + spring-data-orientdb-graph + 0.11 + +``` + +### Document API +```xml + + com.orientechnologies + spring-data-orientdb-document + 0.11 + +``` + +### Object API ```xml com.orientechnologies From 51c99f453df88189646139226e1a7359ca42cd4c Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 2 Jun 2016 14:23:54 +0200 Subject: [PATCH 07/41] fixes dependencies versions --- pom.xml | 11 ----------- .../spring-boot-orientdb-hello/pom.xml | 11 +++-------- .../spring-boot-orientdb-shiro/pom.xml | 8 ++++---- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 0fc1b4b..0749575 100644 --- a/pom.xml +++ b/pom.xml @@ -97,17 +97,6 @@ true - diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index c15c875..6520cd8 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -20,9 +20,9 @@ - org.springframework.boot + com.orientechnologies spring-boot-orientdb-autoconfigure - ${project.version} + ${parent.version} org.springframework.boot @@ -35,15 +35,10 @@ spring-boot-starter-test test - - org.hibernate.javax.persistence - hibernate-jpa-2.0-api - 1.0.1.Final - com.orientechnologies spring-data-orientdb-object - 0.12-SNAPSHOT + ${parent.version} diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index a37e841..223b817 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -32,9 +32,9 @@ - org.springframework.boot + com.orientechnologies spring-boot-orientdb-autoconfigure - ${project.version} + ${parent.version} org.springframework.boot @@ -80,12 +80,12 @@ com.orientechnologies spring-data-orientdb-commons - 0.12-SNAPSHOT + ${parent.version} com.orientechnologies spring-data-orientdb-object - 0.12-SNAPSHOT + ${parent.version} From 73c6d46f75ef01cb4ed8132d880dcf85ea75c256 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 11 Aug 2016 12:37:18 +0200 Subject: [PATCH 08/41] updated to orientDB 2.2.6 --- pom.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0749575..fd4d7fb 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 1.7.13 1.1.3 - 2.2.0 + 2.2.6 1.8.7 4.2.4.RELEASE 1.11.2.RELEASE @@ -145,6 +145,14 @@ +1 + + r.franchini + Roberto Franchini + r.franchini@orientdb.com + OrientDB + http://orientdb.com + +1 + trainings Dzmitry Naskou From 394631d5bf4431ad2fdf26f63357fc268f1e3965 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Fri, 12 Aug 2016 13:56:18 +0200 Subject: [PATCH 09/41] adds gradle dependency section refs https://github.com/orientechnologies/spring-data-orientdb/issues/50 --- README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2d41422..49b494f 100644 --- a/README.md +++ b/README.md @@ -9,31 +9,49 @@ The document module is based on the [Spring Data MongoDB](http://projects.spring [![Build Status](https://drone.io/github.com/vidakovic/spring-data-orientdb/status.png)](https://drone.io/github.com/vidakovic/spring-data-orientdb/latest) -To include OrientDB Spring Data in your Java project via Maven, put one of the snippets below in your pom.xml +To include OrientDB Spring Data in your Java project via Maven, put one of the snippets below in your pom.xml or build.gradle ### Graph API + +Maven: ```xml com.orientechnologies spring-data-orientdb-graph - 0.11 + 0.12 ``` +Gradle: +```groovy + group: 'com.orientechnologies', name: 'spring-data-orientdb-graph', version: '0.12' +``` + + ### Document API ```xml com.orientechnologies spring-data-orientdb-document - 0.11 + 0.12 ``` +Gradle: +```groovy + group: 'com.orientechnologies', name: 'spring-data-orientdb-document', version: '0.12' +``` + ### Object API ```xml com.orientechnologies spring-data-orientdb-object - 0.11 + 0.12 ``` + +Gradle: +```groovy + group: 'com.orientechnologies', name: 'spring-data-orientdb-object', version: '0.12' +``` From ecf8d0f42636d079fb7f038d569623c12463220b Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 15 Aug 2016 09:46:13 +0200 Subject: [PATCH 10/41] cleanup implementation avoiding deprecated methods --- pom.xml | 2 +- .../orient/OrientAutoConfiguration.java | 15 +++--- .../orient/OrientProperties.java | 16 ++----- .../core/AbstractOrientDatabaseFactory.java | 47 +++++++------------ .../commons/core/OrientDatabaseFactory.java | 18 +++---- .../support/OrientRepositoryFactory.java | 1 + .../object/OrientObjectDatabaseFactory.java | 15 +++--- .../OrientObjectRepositoryFactory.java | 17 +++---- .../repository/PersonRepositoryTest.java | 3 +- .../EmployeeClusteredRepositoryTest.java | 11 +++-- .../object/util/OrientOperationUtilTest.java | 14 +++--- .../spring-boot-orientdb-shiro/pom.xml | 7 +++ .../boot/orient/sample/shiro/Application.java | 13 +++-- .../shiro/shiro/HazelcastSessionDao.java | 4 +- .../sample/shiro/rest/UserControllerTest.java | 10 ++-- 15 files changed, 94 insertions(+), 99 deletions(-) diff --git a/pom.xml b/pom.xml index fd4d7fb..9e096a2 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 1.7.13 1.1.3 - 2.2.6 + 2.2.7 1.8.7 4.2.4.RELEASE 1.11.2.RELEASE diff --git a/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientAutoConfiguration.java b/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientAutoConfiguration.java index f0ddf2a..ce71508 100644 --- a/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientAutoConfiguration.java +++ b/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientAutoConfiguration.java @@ -4,18 +4,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.orient.commons.core.OrientDatabaseFactory; -import org.springframework.data.orient.commons.core.OrientOperations; import org.springframework.data.orient.commons.core.OrientTransactionManager; +import org.springframework.data.orient.commons.web.config.OrientWebConfigurer; import org.springframework.data.orient.object.OrientObjectDatabaseFactory; import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.data.orient.object.OrientObjectTemplate; -import org.springframework.data.orient.commons.web.config.OrientWebConfigurer; import org.springframework.transaction.PlatformTransactionManager; @Configuration @@ -25,21 +23,21 @@ public class OrientAutoConfiguration { @Autowired private OrientProperties properties; - + @Bean - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @ConditionalOnMissingBean(PlatformTransactionManager.class) public PlatformTransactionManager transactionManager(OrientDatabaseFactory factory) { return new OrientTransactionManager(factory); } - + @Bean @ConditionalOnMissingBean(OrientObjectDatabaseFactory.class) public OrientObjectDatabaseFactory objectDatabaseFactory() { OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); - + configure(factory); - + return factory; } @@ -63,7 +61,6 @@ protected void configure(OrientDatabaseFactory factory) { factory.setUrl(properties.getUrl()); factory.setUsername(properties.getUsername()); factory.setPassword(properties.getPassword()); - factory.setMaxPoolSize(properties.getMinPoolSize()); factory.setMaxPoolSize(properties.getMaxPoolSize()); } diff --git a/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java b/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java index 0ab750a..fa628c7 100644 --- a/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java +++ b/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java @@ -7,13 +7,12 @@ public class OrientProperties { private String url; - + private String username; - + private String password; - - private int minPoolSize = OrientDatabaseFactory.DEFAULT_MIN_POOL_SIZE; - + + private int maxPoolSize = OrientDatabaseFactory.DEFAULT_MAX_POOL_SIZE; public String getUrl() { @@ -40,13 +39,6 @@ public void setPassword(String password) { this.password = password; } - public int getMinPoolSize() { - return minPoolSize; - } - - public void setMinPoolSize(int minPoolSize) { - this.minPoolSize = minPoolSize; - } public int getMaxPoolSize() { return maxPoolSize; diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java index b0f611d..2a93fbd 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java @@ -13,37 +13,43 @@ /** * A base factory for creating {@link com.orientechnologies.orient.core.db.ODatabase} objects. * - * @author Dzmitry_Naskou * @param the type of database to handle + * @author Dzmitry_Naskou */ public abstract class AbstractOrientDatabaseFactory implements OrientDatabaseFactory { - /** The logger. */ + /** + * The logger. + */ private static Logger log = LoggerFactory.getLogger(AbstractOrientDatabaseFactory.class); - /** The username. */ + /** + * The username. + */ protected String username = DEFAULT_USERNAME; - /** The password. */ + /** + * The password. + */ protected String password = DEFAULT_PASSWORD; - /** The min pool size. */ - protected int minPoolSize = DEFAULT_MIN_POOL_SIZE; - /** The max pool size. */ + /** + * The max pool size. + */ protected int maxPoolSize = DEFAULT_MAX_POOL_SIZE; protected Boolean autoCreate; protected String url; - + @PostConstruct public void init() { notNull(url); notNull(username); notNull(password); - if(autoCreate==null) { + if (autoCreate == null) { autoCreate = !getUrl().startsWith("remote:"); } @@ -65,13 +71,13 @@ public void init() { public ODatabase db() { ODatabase db; - if(!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { + if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { db = openDatabase(); log.debug("acquire db from pool {}", db.hashCode()); } else { - db = (ODatabase)ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); + db = (ODatabase) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); - if(db.isClosed()) { + if (db.isClosed()) { db = openDatabase(); log.debug("re-opened db {}", db.hashCode()); } else { @@ -145,23 +151,6 @@ public void setPassword(String password) { this.password = password; } - /** - * Gets the min pool size. - * - * @return the min pool size - */ - public int getMinPoolSize() { - return minPoolSize; - } - - /** - * Sets the min pool size. - * - * @param minPoolSize the new min pool size - */ - public void setMinPoolSize(int minPoolSize) { - this.minPoolSize = minPoolSize; - } /** * Gets the max pool size. diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java index 7eebf11..b59045d 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java @@ -3,16 +3,20 @@ import com.orientechnologies.orient.core.db.ODatabase; public interface OrientDatabaseFactory { - /** Default database username. */ + /** + * Default database username. + */ public static final String DEFAULT_USERNAME = "admin"; - /** Default database password. */ + /** + * Default database password. + */ public static final String DEFAULT_PASSWORD = "admin"; - /** Default minimum pool size. */ - public static final int DEFAULT_MIN_POOL_SIZE = 1; - /** Default maximum pool size. */ + /** + * Default maximum pool size. + */ public static final int DEFAULT_MAX_POOL_SIZE = 20; public ODatabase db(); @@ -31,10 +35,6 @@ public interface OrientDatabaseFactory { void setPassword(String password); - int getMinPoolSize(); - - void setMinPoolSize(int minPoolSize); - int getMaxPoolSize(); void setMaxPoolSize(int maxPoolSize); diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactory.java index 5b81d93..45ca505 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactory.java @@ -10,6 +10,7 @@ import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.RepositoryFactorySupport; +import org.springframework.data.repository.query.EvaluationContextProvider; import org.springframework.data.repository.query.QueryLookupStrategy; import org.springframework.data.repository.query.QueryLookupStrategy.Key; diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java index 7b72498..986ed15 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java @@ -1,6 +1,6 @@ package org.springframework.data.orient.object; -import com.orientechnologies.orient.object.db.OObjectDatabasePool; +import com.orientechnologies.orient.core.db.OPartitionedDatabasePool; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; import org.springframework.data.orient.commons.core.AbstractOrientDatabaseFactory; @@ -12,20 +12,23 @@ */ public class OrientObjectDatabaseFactory extends AbstractOrientDatabaseFactory { - private OObjectDatabasePool pool; + private OPartitionedDatabasePool pool; - /** The database. */ + /** + * The database. + */ private OObjectDatabaseTx db; @Override protected void createPool() { - pool = new OObjectDatabasePool(getUrl(), getUsername(), getPassword()); - pool.setup(minPoolSize, maxPoolSize); + pool = new OPartitionedDatabasePool(getUrl(), getUsername(), getPassword()); + + } @Override public OObjectDatabaseTx openDatabase() { - db = pool.acquire(); + db = new OObjectDatabaseTx(pool.acquire()); return db; } diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java index c809a03..d409427 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java @@ -13,6 +13,7 @@ import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.RepositoryFactorySupport; +import org.springframework.data.repository.query.EvaluationContextProvider; import org.springframework.data.repository.query.QueryLookupStrategy; import java.io.Serializable; @@ -34,7 +35,7 @@ public EntityInformation getEntityInformatio } @Override - @SuppressWarnings({ "rawtypes", "unchecked"}) + @SuppressWarnings({"rawtypes", "unchecked"}) protected Object getTargetRepository(RepositoryInformation metadata) { EntityInformation entityInformation = getEntityInformation(metadata.getDomainType()); Class repositoryInterface = metadata.getRepositoryInterface(); @@ -57,7 +58,7 @@ protected Object getTargetRepository(RepositoryInformation metadata) { } @Override - protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key) { + protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key, EvaluationContextProvider evaluationContextProvider) { return OrientQueryLookupStrategy.create(operations, key); } @@ -70,32 +71,32 @@ protected Class getRepositoryBaseClass(RepositoryMetadata metadata) { } } - private boolean isObjectRepository(Class repositoryInterface) { + private boolean isObjectRepository(Class repositoryInterface) { return OrientObjectRepository.class.isAssignableFrom(repositoryInterface); } /** * Get Custom Cluster Name. * Method looks for {@link org.springframework.data.orient.commons.repository.annotation.Source} and {@link org.springframework.data.orient.commons.repository.annotation.Cluster} annotation. - * + *

* If {@link org.springframework.data.orient.commons.repository.annotation.Source} is not null and {@link org.springframework.data.orient.commons.repository.annotation.Source#type()} equals to * {@link org.springframework.data.orient.commons.repository.SourceType#CLUSTER} then returns {@link org.springframework.data.orient.commons.repository.annotation.Source#value()} - * + *

* If {@link org.springframework.data.orient.commons.repository.annotation.Cluster} is not null then returns {@link org.springframework.data.orient.commons.repository.annotation.Cluster#value()} * * @param metadata * @return cluster name or null if it's not defined */ - private String getCustomCluster(RepositoryMetadata metadata){ + private String getCustomCluster(RepositoryMetadata metadata) { Class repositoryInterface = metadata.getRepositoryInterface(); Source source = AnnotationUtils.getAnnotation(repositoryInterface, Source.class); - if(source != null && SourceType.CLUSTER.equals(source.type())){ + if (source != null && SourceType.CLUSTER.equals(source.type())) { return source.value(); } Cluster cluster = AnnotationUtils.getAnnotation(repositoryInterface, Cluster.class); - if (cluster != null){ + if (cluster != null) { return cluster.value(); } return null; diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java index b7882ad..67cf5dc 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java @@ -10,6 +10,7 @@ import org.springframework.data.orient.object.domain.Address; import org.springframework.data.orient.object.domain.Person; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; @@ -24,7 +25,7 @@ import static org.testng.Assert.*; @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@TransactionConfiguration(defaultRollback = true) +@Rollback @TestExecutionListeners( inheritListeners = false, listeners = {DependencyInjectionTestExecutionListener.class}) diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java index 9802b38..399e353 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java @@ -3,8 +3,6 @@ import com.orientechnologies.orient.core.id.ORecordId; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; -import java.util.ArrayList; -import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -16,20 +14,23 @@ import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.data.orient.object.domain.Employee; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + import static org.springframework.data.orient.object.OrientDbObjectTestConfiguration.EMPLOYEE_TMP_CLUSTER; -import org.testng.Assert; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@TransactionConfiguration(defaultRollback = false) +@Rollback @ContextConfiguration(classes = OrientDbObjectTestConfiguration.class) @Transactional public class EmployeeClusteredRepositoryTest extends AbstractTestNGSpringContextTests { diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java index cfb3c37..7d3a1eb 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java @@ -8,9 +8,9 @@ import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.data.orient.object.domain.Address; import org.springframework.data.orient.object.domain.Employee; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -18,7 +18,7 @@ @Configuration @EnableTransactionManagement -@TransactionConfiguration +@Rollback @ContextConfiguration(classes = OrientDbObjectTestConfiguration.class) public class OrientOperationUtilTest extends AbstractTestNGSpringContextTests { @@ -27,7 +27,7 @@ public class OrientOperationUtilTest extends AbstractTestNGSpringContextTests { @Autowired OrientObjectDatabaseFactory factory; - + @BeforeClass public void before() { try (OObjectDatabaseTx db = factory.openDatabase()) { @@ -36,7 +36,7 @@ public void before() { } @Test - public void getRidTest(){ + public void getRidTest() { Address address = new Address(); Assert.assertNull(template.getRid(address)); @@ -45,7 +45,7 @@ public void getRidTest(){ } @Test - public void getRidFromParentTest(){ + public void getRidFromParentTest() { Employee employee = new Employee(); Assert.assertNull(template.getRid(employee)); @@ -54,10 +54,10 @@ public void getRidFromParentTest(){ } @Test - public void getRidFromProxy(){ + public void getRidFromProxy() { Employee employee = new Employee(); Employee savedEmployee = template.save(employee); - + Assert.assertNotSame(savedEmployee.getClass(), Employee.class); Assert.assertEquals(template.getRid(savedEmployee), savedEmployee.getRid()); } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 223b817..2ccbd32 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -128,6 +128,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + true + + diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/Application.java b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/Application.java index 0819541..7886747 100755 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/Application.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/Application.java @@ -2,8 +2,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * + * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -12,18 +12,23 @@ */ package org.springframework.boot.orient.sample.shiro; +import org.springframework.boot.Banner; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.ComponentScan; @EnableAutoConfiguration @ComponentScan -public class Application { +public final class Application { + + private Application() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } public static void main(String... args) { new SpringApplicationBuilder() .sources(Application.class) - .showBanner(false) + .bannerMode(Banner.Mode.OFF) .run(args); } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/shiro/HazelcastSessionDao.java b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/shiro/HazelcastSessionDao.java index 45162c7..6d95d4a 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/shiro/HazelcastSessionDao.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/shiro/HazelcastSessionDao.java @@ -34,8 +34,8 @@ public class HazelcastSessionDao extends AbstractSessionDAO { private static final Logger log = LoggerFactory .getLogger(HazelcastSessionDao.class); - private String hcInstanceName = UUID.randomUUID().toString(); - private IMap map; + private final String hcInstanceName = UUID.randomUUID().toString(); + private final IMap map; private static final String HC_MAP = "sessions"; private static final String HC_GROUP_NAME = "hc"; private static final String HC_GROUP_PASSWORD = "oursessionssecret"; diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java index de88316..f63eff3 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java @@ -2,8 +2,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * + * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -43,12 +43,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.testng.AssertJUnit.assertEquals; -@SpringApplicationConfiguration(classes - = {Application.class, OrientDbConfiguration.class, ShiroConfiguration.class}) +@SpringApplicationConfiguration(classes = {Application.class, OrientDbConfiguration.class, ShiroConfiguration.class}) @WebAppConfiguration @IntegrationTest -@TestExecutionListeners(inheritListeners = false, listeners - = {DependencyInjectionTestExecutionListener.class}) +@TestExecutionListeners(inheritListeners = false, listeners = {DependencyInjectionTestExecutionListener.class}) public class UserControllerTest extends AbstractTestNGSpringContextTests { private final String BASE_URL = "http://localhost:8080/users"; From 7970f78c51880006ef2ad4bc0028f4fa26e2aa1e Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 15 Aug 2016 10:00:41 +0200 Subject: [PATCH 11/41] pom: project.parent.version instead of parent.version --- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 6520cd8..1527b46 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -22,7 +22,7 @@ com.orientechnologies spring-boot-orientdb-autoconfigure - ${parent.version} + ${project.parent.version} org.springframework.boot diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 2ccbd32..4395b87 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -34,7 +34,7 @@ com.orientechnologies spring-boot-orientdb-autoconfigure - ${parent.version} + ${project.parent.version} org.springframework.boot From c5a8e41b7ea1acbf436eb79bb63b2270bee12a2e Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 15 Aug 2016 10:16:02 +0200 Subject: [PATCH 12/41] poms: project.version instead of project.parent.version --- .../spring-boot-orientdb-hello/pom.xml | 4 ++-- .../spring-boot-orientdb-shiro/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 1527b46..5b82deb 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -22,7 +22,7 @@ com.orientechnologies spring-boot-orientdb-autoconfigure - ${project.parent.version} + ${project.version} org.springframework.boot @@ -38,7 +38,7 @@ com.orientechnologies spring-data-orientdb-object - ${parent.version} + ${project.version} diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 4395b87..f6e23cc 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -80,12 +80,12 @@ com.orientechnologies spring-data-orientdb-commons - ${parent.version} + ${project.version} com.orientechnologies spring-data-orientdb-object - ${parent.version} + ${project.version} From bfe509c701fd95beeab23c1300188bb10f67c03b Mon Sep 17 00:00:00 2001 From: robfrank Date: Mon, 15 Aug 2016 11:21:29 +0200 Subject: [PATCH 13/41] releasing OrientDB Spring Data 0.12 --- pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 9e096a2..518f9c2 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 139c81d..0e45c30 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 477599e..1232e22 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 8b46cd3..19bd087 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index d921e21..b3d54a5 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index ccc3d17..d1742b2 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index 37d3321..c28700e 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 5b82deb..dff5898 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index f6e23cc..24bfeb6 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12-SNAPSHOT + 0.12 ../../pom.xml From 030d8045ca397720e35de9021983d1ad2f365e6d Mon Sep 17 00:00:00 2001 From: robfrank Date: Mon, 15 Aug 2016 11:22:47 +0200 Subject: [PATCH 14/41] versions bumped to 0.13-SNAPSHOT --- pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 518f9c2..a0aa7ac 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 0e45c30..c277439 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 1232e22..3964763 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 19bd087..15072c7 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index b3d54a5..596085c 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index d1742b2..147453c 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index c28700e..74acaf7 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index dff5898..8c3660a 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 24bfeb6..4d30f2e 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -7,7 +7,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.12 + 0.13-SNAPSHOT ../../pom.xml From 70d055ae6f63511b754d55e9e1493e66ebd358bb Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Wed, 31 Aug 2016 15:40:37 +0200 Subject: [PATCH 15/41] adds delete support - queryExcution, queryCreator now support deletion - hello example controller and person repository updated with delete refs https://github.com/orientechnologies/spring-data-orientdb/issues/55 --- .../orient/OrientProperties.java | 2 - .../core/AbstractOrientOperations.java | 1117 +++++++++-------- .../commons/core/OrientTransaction.java | 11 +- .../core/OrientTransactionManager.java | 40 +- .../repository/annotation/Cluster.java | 2 +- .../commons/repository/annotation/Detach.java | 2 +- .../repository/annotation/FetchPlan.java | 2 +- .../commons/repository/annotation/Query.java | 4 +- .../commons/repository/annotation/Source.java | 4 +- .../config/OrientRepositoryRegistrar.java | 2 +- .../repository/query/AbstractOrientQuery.java | 69 +- .../repository/query/OrientQueryCreator.java | 150 ++- .../query/OrientQueryExecution.java | 79 +- .../repository/query/PartTreeOrientQuery.java | 37 +- .../query/StringBasedOrientQuery.java | 24 +- .../orientdb/hello/HelloConfiguration.java | 3 +- .../boot/orientdb/hello/data/Person.java | 11 +- .../hello/repository/PersonRepository.java | 9 +- .../orientdb/hello/rest/PersonController.java | 13 +- .../spring-boot-orientdb-shiro/pom.xml | 2 +- 20 files changed, 860 insertions(+), 723 deletions(-) diff --git a/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java b/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java index fa628c7..db940cf 100644 --- a/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java +++ b/spring-boot-orientdb-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orient/OrientProperties.java @@ -12,7 +12,6 @@ public class OrientProperties { private String password; - private int maxPoolSize = OrientDatabaseFactory.DEFAULT_MAX_POOL_SIZE; public String getUrl() { @@ -39,7 +38,6 @@ public void setPassword(String password) { this.password = password; } - public int getMaxPoolSize() { return maxPoolSize; } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java index 6863ed3..4a83154 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java @@ -32,563 +32,568 @@ import java.util.concurrent.Callable; public abstract class AbstractOrientOperations implements OrientOperations { - // private static final Logger logger = LoggerFactory.getLogger(AbstractOrientOperations.class); - - protected final OrientDatabaseFactory dbf; - - protected Set defaultClusters; - - protected AbstractOrientOperations(OrientDatabaseFactory dbf) { - this.dbf = dbf; - } - - @Override - public String getName() { - return dbf.db().getName(); - } - - @Override - public String getURL() { - return dbf.db().getURL(); - } - - @Override - public ODatabase database() { - return dbf.db(); - } - - @Override - public Object setProperty(String name, Object value) { - return dbf.db().setProperty(name, value); - } - - @Override - public Object getProperty(String name) { - return dbf.db().getProperty(name); - } - - @Override - public Iterator> getProperties() { - return dbf.db().getProperties(); - } - - @Override - public Object get(ODatabase.ATTRIBUTES attribute) { - return dbf.db().get(attribute); - } - - @Override - public > DB set(ODatabase.ATTRIBUTES attribute, Object value) { - return dbf.db().set(attribute, value); - } - - @Override - public void registerListener(ODatabaseListener listener) { - dbf.db().registerListener(listener); - } - - @Override - public void unregisterListener(ODatabaseListener listener) { - dbf.db().unregisterListener(listener); - } - - @Override - public Map getHooks() { - return dbf.db().getHooks(); - } - - @Override - public > DB registerHook(ORecordHook hook) { - return dbf.db().registerHook(hook); - } - - @Override - public > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position) { - return dbf.db().registerHook(hook, position); - } - - @Override - public > DB unregisterHook(ORecordHook hook) { - return dbf.db().unregisterHook(hook); - } - - @Override - public void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, - int compressionLevel, int bufferSize) throws IOException { - dbf.db().backup(out, options, callable, listener, compressionLevel, bufferSize); - } - - @Override - public void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) - throws IOException { - dbf.db().restore(in, options, callable, listener); - } - - @Override - public String getType() { - return dbf.db().getType(); - } - - @Override - public long getSize() { - return dbf.db().getSize(); - } - - @Override - public void freeze(boolean throwException) { - dbf.db().freeze(throwException); - } - - @Override - public void freeze() { - dbf.db().freeze(); - } - - @Override - public void release() { - dbf.db().release(); - } - - @Override - public OMetadata getMetadata() { - return dbf.db().getMetadata(); - } - - @Override - public ORecordMetadata getRecordMetadata(ORID rid) { - return dbf.db().getRecordMetadata(rid); - } - - @Override - public ODictionary getDictionary() { - return dbf.db().getDictionary(); - } - - @Override - public boolean declareIntent(OIntent intent) { - return dbf.db().declareIntent(intent); - } - - @Override - public boolean isMVCC() { - return dbf.db().isMVCC(); - } - - @Override - public > DB setMVCC(boolean mvcc) { - return dbf.db().setMVCC(mvcc); - } - - @Override - public boolean isClosed() { - return dbf.db().isClosed(); - } - - @Override - public boolean isDefault(String clusterName) { - loadDefaultClusters(); - return defaultClusters.contains(clusterName); - } - - private void loadDefaultClusters() { - if (defaultClusters == null) { - synchronized (this) { + // private static final Logger logger = LoggerFactory.getLogger(AbstractOrientOperations.class); + + protected final OrientDatabaseFactory dbf; + + protected Set defaultClusters; + + protected AbstractOrientOperations(OrientDatabaseFactory dbf) { + this.dbf = dbf; + } + + @Override + public String getName() { + return dbf.db().getName(); + } + + @Override + public String getURL() { + return dbf.db().getURL(); + } + + @Override + public ODatabase database() { + return dbf.db(); + } + + @Override + public Object setProperty(String name, Object value) { + return dbf.db().setProperty(name, value); + } + + @Override + public Object getProperty(String name) { + return dbf.db().getProperty(name); + } + + @Override + public Iterator> getProperties() { + return dbf.db().getProperties(); + } + + @Override + public Object get(ODatabase.ATTRIBUTES attribute) { + return dbf.db().get(attribute); + } + + @Override + public > DB set(ODatabase.ATTRIBUTES attribute, Object value) { + return dbf.db().set(attribute, value); + } + + @Override + public void registerListener(ODatabaseListener listener) { + dbf.db().registerListener(listener); + } + + @Override + public void unregisterListener(ODatabaseListener listener) { + dbf.db().unregisterListener(listener); + } + + @Override + public Map getHooks() { + return dbf.db().getHooks(); + } + + @Override + public > DB registerHook(ORecordHook hook) { + return dbf.db().registerHook(hook); + } + + @Override + public > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position) { + return dbf.db().registerHook(hook, position); + } + + @Override + public > DB unregisterHook(ORecordHook hook) { + return dbf.db().unregisterHook(hook); + } + + @Override + public void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, + int compressionLevel, int bufferSize) throws IOException { + dbf.db().backup(out, options, callable, listener, compressionLevel, bufferSize); + } + + @Override + public void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) + throws IOException { + dbf.db().restore(in, options, callable, listener); + } + + @Override + public String getType() { + return dbf.db().getType(); + } + + @Override + public long getSize() { + return dbf.db().getSize(); + } + + @Override + public void freeze(boolean throwException) { + dbf.db().freeze(throwException); + } + + @Override + public void freeze() { + dbf.db().freeze(); + } + + @Override + public void release() { + dbf.db().release(); + } + + @Override + public OMetadata getMetadata() { + return dbf.db().getMetadata(); + } + + @Override + public ORecordMetadata getRecordMetadata(ORID rid) { + return dbf.db().getRecordMetadata(rid); + } + + @Override + public ODictionary getDictionary() { + return dbf.db().getDictionary(); + } + + @Override + public boolean declareIntent(OIntent intent) { + return dbf.db().declareIntent(intent); + } + + @Override + public boolean isMVCC() { + return dbf.db().isMVCC(); + } + + @Override + public > DB setMVCC(boolean mvcc) { + return dbf.db().setMVCC(mvcc); + } + + @Override + public boolean isClosed() { + return dbf.db().isClosed(); + } + + @Override + public boolean isDefault(String clusterName) { + loadDefaultClusters(); + return defaultClusters.contains(clusterName); + } + + private void loadDefaultClusters() { if (defaultClusters == null) { - defaultClusters = new HashSet<>(); - for (OClass oClass : dbf.db().getMetadata().getSchema().getClasses()) { - String defaultCluster = getClusterNameById(oClass.getDefaultClusterId()); - defaultClusters.add(defaultCluster); - } + synchronized (this) { + if (defaultClusters == null) { + defaultClusters = new HashSet<>(); + for (OClass oClass : dbf.db().getMetadata().getSchema().getClasses()) { + String defaultCluster = getClusterNameById(oClass.getDefaultClusterId()); + defaultClusters.add(defaultCluster); + } + } + } } - } - } - } - - @Override - public void reload() { - dbf.db().reload(); - } - - @Override - public T reload(T entity, String fetchPlan, boolean ignoreCache) { - return dbf.db().reload(entity, fetchPlan, ignoreCache); - } - - @Override - public ODatabase.STATUS getStatus() { - return dbf.db().getStatus(); - } - - @Override - public > DB setStatus(ODatabase.STATUS status) { - return dbf.db().setStatus(status); - } - - @Override - public OTransaction getTransaction() { - return dbf.db().getTransaction(); - } - - @Override - public ODatabase begin() { - return dbf.db().begin(); - } - - @Override - public ODatabase begin(OTransaction.TXTYPE type) { - return dbf.db().begin(type); - } - - @Override - public ODatabase begin(OTransaction tx) { - return dbf.db().begin(tx); - } - - @Override - public ODatabase commit() { - return dbf.db().commit(); - } - - @Override - public ODatabase commit(boolean force) throws OTransactionException { - return dbf.db().commit(force); - } - - @Override - public ODatabase rollback() { - return dbf.db().rollback(); - } - - @Override - public ODatabase rollback(boolean force) throws OTransactionException { - return dbf.db().rollback(force); - } - - @Override - public OLocalRecordCache getLevel2Cache() { - return dbf.db().getLocalCache(); - } - - @Override - public T newInstance() { - return dbf.db().newInstance(); - } - - @Override - public T load(ORID recordId) { - return dbf.db().load(recordId); - } - - @Override - public T load(String recordId) { - return load(new ORecordId(recordId)); - } - - public T load(T entity) { - return dbf.db().load(entity); - } - - @Override - public T load(T entity, String fetchPlan) { - return dbf.db().load(entity, fetchPlan); - } - - @Override - public T load(T entity, String fetchPlan, boolean ignoreCache) { - return dbf.db().load(entity, fetchPlan, ignoreCache); - } - - @Override - public T load(ORID recordId, String fetchPlan) { - return dbf.db().load(recordId, fetchPlan); - } - - @Override - public T load(ORID recordId, String fetchPlan, boolean ignoreCache) { - return dbf.db().load(recordId, fetchPlan, ignoreCache); - } - - @Override - public T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy) { - return dbf.db().load(entity, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); - } - - @Override - public T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, - OStorage.LOCKING_STRATEGY lockingStrategy) { - return dbf.db().load(recordId, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); - } - - @Override - public S save(S entity) { - return dbf.db().save(entity); - } - - @Override - public S save(S entity, String cluster) { - return dbf.db().save(entity, cluster); - } - - @Override - public S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, - ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback) { - return dbf.db().save(entity, mode, forceCreate, recordCallback, recordUpdatedCallback); - } - - @Override - public long countClass(Class clazz) { - return count(new OSQLSynchQuery("select count(*) from " + clazz.getSimpleName())); - } - - @Override - public long countClass(String className) { - return count(new OSQLSynchQuery("select count(*) from " + className)); - } - - @Override - public long count(OSQLQuery query, Object... args) { - return ((ODocument) dbf.db().query(query, args).get(0)).field("count"); - } - - @Override - public long countClusterElements(String clusterName) { - return dbf.db().countClusterElements(clusterName); - } - - @Override - public long countClusterElements(int clusterId) { - return dbf.db().countClusterElements(clusterId); - } - - @Override - public long countClusterElements(int[] clusterIds) { - return dbf.db().countClusterElements(clusterIds); - } - - @Override - public long countClusterElements(int iClusterId, boolean countTombstones) { - return dbf.db().countClusterElements(iClusterId, countTombstones); - } - - @Override - public long countClusterElements(int[] iClusterIds, boolean countTombstones) { - return dbf.db().countClusterElements(iClusterIds, countTombstones); - } - - @Override - public int getClusters() { - return dbf.db().getClusters(); - } - - @Override - public boolean existsCluster(String clusterName) { - return dbf.db().existsCluster(clusterName); - } - - @Override - public Collection getClusterNames() { - return dbf.db().getClusterNames(); - } - - @Override - public int getClusterIdByName(String clusterName, Class clazz) { - OClass oClass = dbf.db().getMetadata().getSchema().getClass(clazz); - for (int clusterId : oClass.getClusterIds()) { - if (getClusterNameById(clusterId).equals(clusterName)) { - return clusterId; - } - } - - throw new IllegalArgumentException("Cluster " + clusterName + " not found"); - } - - @Override - public String getClusterNameByRid(String rid) { - return getClusterNameById(new ORecordId(rid).getClusterId()); - } - - @Override - public List getClusterNamesByClass(Class clazz, boolean showDefault) { - int[] clusterIds = dbf.db().getMetadata().getSchema().getClass(clazz).getClusterIds(); - int defaultCluster = getDefaultClusterId(clazz); - - List clusters = new ArrayList<>(clusterIds.length); - for (int clusterId : clusterIds) { - if (showDefault || clusterId != defaultCluster) { - clusters.add(getClusterNameById(clusterId)); - } - } - - return clusters; - } - - @Override - public int getDefaultClusterId(Class domainClass) { - return dbf.db().getMetadata().getSchema().getClass(domainClass).getDefaultClusterId(); - } - - @Override - public long getClusterRecordSizeById(int clusterId) { - return dbf.db().getClusterRecordSizeById(clusterId); - } - - @Override - public long getClusterRecordSizeByName(String clusterName) { - return dbf.db().getClusterRecordSizeByName(clusterName); - } - - @Override - public int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params) { - return dbf.db().addCluster(type, clusterName, location, dataSegmentName, params); - } - - @Override - public int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, - Object... params) { - return dbf.db().addCluster(type, clusterName, requestedId, location, dataSegmentName, params); - } - - @Override - public int addCluster(String clusterName, Object... params) { - return dbf.db().addCluster(clusterName, params); - } - - @Override - public int addCluster(String clusterName) { - return dbf.db().addCluster(clusterName); - } - - @Override - public ODatabase delete(ORID recordId) { - return dbf.db().delete(recordId); - } - - @Override - public ODatabase delete(T entity) { - return dbf.db().delete(entity); - } - - @Override - public ODatabase delete(ORID rid, int version) { - return dbf.db().delete(rid, version); - } - - @Override - public int getDefaultClusterId() { - return dbf.db().getDefaultClusterId(); - } - - @Override - public String getClusterNameById(int clusterId) { - return dbf.db().getClusterNameById(clusterId); - } - - @Override - public int getClusterIdByName(String clusterName) { - return dbf.db().getClusterIdByName(clusterName); - } - - @Override - public boolean existsClass(Class clazz) { - return existsClass(clazz.getSimpleName()); - } - - @Override - public boolean existsClass(String className) { - return dbf.db().getMetadata().getSchema().existsClass(className); - } - - @Override - public OSecurityUser getUser() { - return dbf.db().getUser(); - } - - @Override - @SuppressWarnings("unchecked") - public > RET detach(RET entities) { - List result = new ArrayList<>(entities.size()); - - for (Object entity : entities) { - result.add(detach(entity)); - } - - return (RET) result; - } - - @Override - @SuppressWarnings("unchecked") - public > RET detachAll(RET entities) { - List result = new ArrayList<>(entities.size()); - - for (Object entity : entities) { - result.add(detachAll(entity)); - } - - return (RET) result; - } - - @Override - public > RET query(OQuery query, Object... args) { - return dbf.db().query(query, args); - } - - @Override - public > RET query(OQuery query, DetachMode detachMode, Object... args) { - RET result = query(query, args); - - switch (detachMode) { - case ENTITY: - return detach(result); - case ALL: - return detachAll(result); - case NONE: - } - - return result; - } - - @Override - @SuppressWarnings("unchecked") - public RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args) { - RET result = queryForObject(query, args); - - switch (detachMode) { - case ENTITY: - return detach(result); - case ALL: - return detachAll(result); - case NONE: - } - - return result; - } - - @Override - @SuppressWarnings("unchecked") - public RET queryForObject(OSQLQuery query, Object... args) { - return (RET) query(query, args).get(0); - } - - @Override - public RET command(OCommandRequest command) { - return dbf.db().command(command); - } - - @Override - public RET command(OCommandSQL command, Object... args) { - return dbf.db().command(command).execute(args); - } - - @Override - public RET command(String sql, Object... args) { - return dbf.db().command(new OCommandSQL(sql)).execute(args); - } - - public boolean equals(Object other) { - return dbf.db().equals(other); - } + } + + @Override + public void reload() { + dbf.db().reload(); + } + + @Override + public T reload(T entity, String fetchPlan, boolean ignoreCache) { + return dbf.db().reload(entity, fetchPlan, ignoreCache); + } + + @Override + public ODatabase.STATUS getStatus() { + return dbf.db().getStatus(); + } + + @Override + public > DB setStatus(ODatabase.STATUS status) { + return dbf.db().setStatus(status); + } + + @Override + public OTransaction getTransaction() { + return dbf.db().getTransaction(); + } + + @Override + public ODatabase begin() { + return dbf.db().begin(); + } + + @Override + public ODatabase begin(OTransaction.TXTYPE type) { + return dbf.db().begin(type); + } + + @Override + public ODatabase begin(OTransaction tx) { + return dbf.db().begin(tx); + } + + @Override + public ODatabase commit() { + return dbf.db().commit(); + } + + @Override + public ODatabase commit(boolean force) throws OTransactionException { + return dbf.db().commit(force); + } + + @Override + public ODatabase rollback() { + return dbf.db().rollback(); + } + + @Override + public ODatabase rollback(boolean force) throws OTransactionException { + return dbf.db().rollback(force); + } + + @Override + public OLocalRecordCache getLevel2Cache() { + return dbf.db().getLocalCache(); + } + + @Override + public T newInstance() { + return dbf.db().newInstance(); + } + + @Override + public T load(ORID recordId) { + return dbf.db().load(recordId); + } + + @Override + public T load(String recordId) { + return load(new ORecordId(recordId)); + } + + public T load(T entity) { + return dbf.db().load(entity); + } + + @Override + public T load(T entity, String fetchPlan) { + return dbf.db().load(entity, fetchPlan); + } + + @Override + public T load(T entity, String fetchPlan, boolean ignoreCache) { + return dbf.db().load(entity, fetchPlan, ignoreCache); + } + + @Override + public T load(ORID recordId, String fetchPlan) { + return dbf.db().load(recordId, fetchPlan); + } + + @Override + public T load(ORID recordId, String fetchPlan, boolean ignoreCache) { + return dbf.db().load(recordId, fetchPlan, ignoreCache); + } + + @Override + public T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy) { + return dbf.db().load(entity, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); + } - public String toString() { - return dbf.db().toString(); - } + @Override + public T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, + OStorage.LOCKING_STRATEGY lockingStrategy) { + return dbf.db().load(recordId, fetchPlan, ignoreCache, loadTombstone, lockingStrategy); + } + + @Override + public S save(S entity) { + return dbf.db().save(entity); + } + + @Override + public S save(S entity, String cluster) { + return dbf.db().save(entity, cluster); + } + + @Override + public S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, + ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback) { + return dbf.db().save(entity, mode, forceCreate, recordCallback, recordUpdatedCallback); + } + + @Override + public long countClass(Class clazz) { + return count(new OSQLSynchQuery("select count(*) from " + clazz.getSimpleName())); + } + + @Override + public long countClass(String className) { + return count(new OSQLSynchQuery("select count(*) from " + className)); + } + + @Override + public long count(OSQLQuery query, Object... args) { + return ((ODocument) dbf.db().query(query, args).get(0)).field("count"); + } + + @Override + public long countClusterElements(String clusterName) { + return dbf.db().countClusterElements(clusterName); + } + + @Override + public long countClusterElements(int clusterId) { + return dbf.db().countClusterElements(clusterId); + } + + @Override + public long countClusterElements(int[] clusterIds) { + return dbf.db().countClusterElements(clusterIds); + } + + @Override + public long countClusterElements(int iClusterId, boolean countTombstones) { + return dbf.db().countClusterElements(iClusterId, countTombstones); + } + + @Override + public long countClusterElements(int[] iClusterIds, boolean countTombstones) { + return dbf.db().countClusterElements(iClusterIds, countTombstones); + } + + @Override + public int getClusters() { + return dbf.db().getClusters(); + } + + @Override + public boolean existsCluster(String clusterName) { + return dbf.db().existsCluster(clusterName); + } + + @Override + public Collection getClusterNames() { + return dbf.db().getClusterNames(); + } + + @Override + public int getClusterIdByName(String clusterName, Class clazz) { + OClass oClass = dbf.db().getMetadata().getSchema().getClass(clazz); + for (int clusterId : oClass.getClusterIds()) { + if (getClusterNameById(clusterId).equals(clusterName)) { + return clusterId; + } + } + + throw new IllegalArgumentException("Cluster " + clusterName + " not found"); + } + + @Override + public String getClusterNameByRid(String rid) { + return getClusterNameById(new ORecordId(rid).getClusterId()); + } + + @Override + public List getClusterNamesByClass(Class clazz, boolean showDefault) { + int[] clusterIds = dbf.db().getMetadata().getSchema().getClass(clazz).getClusterIds(); + int defaultCluster = getDefaultClusterId(clazz); + + List clusters = new ArrayList<>(clusterIds.length); + for (int clusterId : clusterIds) { + if (showDefault || clusterId != defaultCluster) { + clusters.add(getClusterNameById(clusterId)); + } + } + + return clusters; + } + + @Override + public int getDefaultClusterId(Class domainClass) { + return dbf.db().getMetadata().getSchema().getClass(domainClass).getDefaultClusterId(); + } + + @Override + public long getClusterRecordSizeById(int clusterId) { + return dbf.db().getClusterRecordSizeById(clusterId); + } + + @Override + public long getClusterRecordSizeByName(String clusterName) { + return dbf.db().getClusterRecordSizeByName(clusterName); + } + + @Override + public int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params) { + return dbf.db().addCluster(type, clusterName, location, dataSegmentName, params); + } + + @Override + public int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, + Object... params) { + return dbf.db().addCluster(type, clusterName, requestedId, location, dataSegmentName, params); + } + + @Override + public int addCluster(String clusterName, Object... params) { + return dbf.db().addCluster(clusterName, params); + } + + @Override + public int addCluster(String clusterName) { + return dbf.db().addCluster(clusterName); + } + + @Override + public ODatabase delete(ORID recordId) { + return dbf.db().delete(recordId); + } + + @Override + public ODatabase delete(T entity) { + return dbf.db().delete(entity); + } + + @Override + public ODatabase delete(ORID rid, int version) { + return dbf.db().delete(rid, version); + } + + @Override + public int getDefaultClusterId() { + return dbf.db().getDefaultClusterId(); + } + + @Override + public String getClusterNameById(int clusterId) { + return dbf.db().getClusterNameById(clusterId); + } + + @Override + public int getClusterIdByName(String clusterName) { + return dbf.db().getClusterIdByName(clusterName); + } + + @Override + public boolean existsClass(Class clazz) { + return existsClass(clazz.getSimpleName()); + } + + @Override + public boolean existsClass(String className) { + return dbf.db().getMetadata().getSchema().existsClass(className); + } + + @Override + public OSecurityUser getUser() { + return dbf.db().getUser(); + } + + @Override + @SuppressWarnings("unchecked") + public > RET detach(RET entities) { + List result = new ArrayList<>(entities.size()); + + for (Object entity : entities) { + result.add(detach(entity)); + } + + return (RET) result; + } + + @Override + @SuppressWarnings("unchecked") + public > RET detachAll(RET entities) { + List result = new ArrayList<>(entities.size()); + + for (Object entity : entities) { + result.add(detachAll(entity)); + } + + return (RET) result; + } + + @Override + public > RET query(OQuery query, Object... args) { + return dbf.db().query(query, args); + } + + @Override + public > RET query(OQuery query, DetachMode detachMode, Object... args) { + RET result = query(query, args); + + switch (detachMode) { + case ENTITY: + return detach(result); + case ALL: + return detachAll(result); + case NONE: + } + + return result; + } + + @Override + @SuppressWarnings("unchecked") + public RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args) { + RET result = queryForObject(query, args); + + switch (detachMode) { + case ENTITY: + return detach(result); + case ALL: + return detachAll(result); + case NONE: + } + + return result; + } + + @Override + @SuppressWarnings("unchecked") + public RET queryForObject(OSQLQuery query, Object... args) { + List objects = query(query, args); + + if (objects.size() > 0) + return (RET) objects.get(0); + + return null; + } + + @Override + public RET command(OCommandRequest command) { + return dbf.db().command(command); + } + + @Override + public RET command(OCommandSQL command, Object... args) { + return dbf.db().command(command).execute(args); + } + + @Override + public RET command(String sql, Object... args) { + return dbf.db().command(new OCommandSQL(sql)).execute(args); + } + + public boolean equals(Object other) { + return dbf.db().equals(other); + } + + public String toString() { + return dbf.db().toString(); + } } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransaction.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransaction.java index 89f6253..55f0eeb 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransaction.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransaction.java @@ -1,20 +1,23 @@ package org.springframework.data.orient.commons.core; import com.orientechnologies.orient.core.db.ODatabase; -import com.orientechnologies.orient.core.db.ODatabaseInternal; import com.orientechnologies.orient.core.tx.OTransaction; /** * The specific Orient Transaction. - * + * * @author Dzmitry_Naskou */ public class OrientTransaction { - /** The orient tx object. */ + /** + * The orient tx object. + */ private OTransaction tx; - /** The database. */ + /** + * The database. + */ private ODatabase database; public OTransaction getTx() { diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransactionManager.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransactionManager.java index d1cae4b..2ea03a0 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransactionManager.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientTransactionManager.java @@ -16,17 +16,21 @@ /** * {@link org.springframework.transaction.PlatformTransactionManager} implementation * for OrientDB. - * + * * @author Dzmitry_Naskou */ public class OrientTransactionManager extends AbstractPlatformTransactionManager implements ResourceTransactionManager { private static final long serialVersionUID = 1L; - /** The logger. */ + /** + * The logger. + */ private static Logger log = LoggerFactory.getLogger(OrientTransactionManager.class); - /** The database factory. */ + /** + * The database factory. + */ private OrientDatabaseFactory dbf; /** @@ -47,7 +51,7 @@ protected Object doGetTransaction() throws TransactionException { OrientTransaction tx = new OrientTransaction(); ODatabase db = (ODatabase) TransactionSynchronizationManager.getResource(getResourceFactory()); - + if (db != null) { tx.setDatabase(db); tx.setTx(db.getTransaction()); @@ -55,14 +59,14 @@ protected Object doGetTransaction() throws TransactionException { return tx; } - + /* (non-Javadoc) * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#isExistingTransaction(java.lang.Object) */ @Override protected boolean isExistingTransaction(Object transaction) throws TransactionException { OrientTransaction tx = (OrientTransaction) transaction; - + return tx.getTx() != null && tx.getTx().isActive(); } @@ -79,9 +83,9 @@ protected void doBegin(Object transaction, TransactionDefinition definition) thr tx.setDatabase(db); TransactionSynchronizationManager.bindResource(dbf, db); } - + log.debug("beginning transaction, db.hashCode() = {}", db.hashCode()); - + db.begin(); } @@ -92,9 +96,9 @@ protected void doBegin(Object transaction, TransactionDefinition definition) thr protected void doCommit(DefaultTransactionStatus status) throws TransactionException { OrientTransaction tx = (OrientTransaction) status.getTransaction(); ODatabase db = tx.getDatabase(); - + log.debug("committing transaction, db.hashCode() = {}", db.hashCode()); - + db.commit(); } @@ -105,12 +109,12 @@ protected void doCommit(DefaultTransactionStatus status) throws TransactionExcep protected void doRollback(DefaultTransactionStatus status) throws TransactionException { OrientTransaction tx = (OrientTransaction) status.getTransaction(); ODatabase db = tx.getDatabase(); - + log.debug("rolling back transaction, db.hashCode() = {}", db.hashCode()); - + db.rollback(); } - + /* (non-Javadoc) * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doSetRollbackOnly(org.springframework.transaction.support.DefaultTransactionStatus) */ @@ -125,15 +129,15 @@ protected void doSetRollbackOnly(DefaultTransactionStatus status) throws Transac @Override protected void doCleanupAfterCompletion(Object transaction) { OrientTransaction tx = (OrientTransaction) transaction; - + if (!tx.getDatabase().isClosed()) { log.debug("closing transaction, db.hashCode() = {}", tx.getDatabase().hashCode()); tx.getDatabase().close(); } - + TransactionSynchronizationManager.unbindResource(dbf); } - + /* (non-Javadoc) * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doSuspend(java.lang.Object) */ @@ -143,7 +147,7 @@ protected Object doSuspend(Object transaction) throws TransactionException { return tx.getDatabase(); } - + /* (non-Javadoc) * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doResume(java.lang.Object, java.lang.Object) */ @@ -151,7 +155,7 @@ protected Object doSuspend(Object transaction) throws TransactionException { protected void doResume(Object transaction, Object suspendedResources) throws TransactionException { OrientTransaction tx = (OrientTransaction) transaction; ODatabase db = tx.getDatabase(); - + if (!db.isClosed()) { db.close(); } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Cluster.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Cluster.java index 120f721..18b7d74 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Cluster.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Cluster.java @@ -4,7 +4,7 @@ /** * The annotation to declare orient cluster. - * + * * @author Dzmitry_Naskou */ @Documented diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Detach.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Detach.java index 5b3ce79..2fef06f 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Detach.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Detach.java @@ -6,7 +6,7 @@ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) +@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) public @interface Detach { DetachMode value(); diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/FetchPlan.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/FetchPlan.java index 2f9ce23..9bb8fa3 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/FetchPlan.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/FetchPlan.java @@ -4,7 +4,7 @@ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) +@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) public @interface FetchPlan { String value(); diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Query.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Query.java index 17d1c7d..6682b68 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Query.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Query.java @@ -4,7 +4,7 @@ /** * The annotation to declare custom queries directly on repository methods. - * + * * @author Dzmitry_Naskou */ @Documented @@ -16,7 +16,7 @@ * Defines the Orient query to be executed when the annotated method is called. */ String value() default ""; - + /** * Defines a special count query that shall be used for pagination queries to lookup the total number of elements for * a page. If non is configured we will derive the count query from the method name. diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Source.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Source.java index d2b28bc..8976efa 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Source.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/annotation/Source.java @@ -6,7 +6,7 @@ /** * The annotation to declare orient source (class or cluster). - * + * * @author Dzmitry_Naskou */ @Documented @@ -20,7 +20,7 @@ * @return the source type */ SourceType type() default SourceType.CLUSTER; - + /** * Defines the Orient cluster name. */ diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/config/OrientRepositoryRegistrar.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/config/OrientRepositoryRegistrar.java index ac0768f..2cda111 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/config/OrientRepositoryRegistrar.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/config/OrientRepositoryRegistrar.java @@ -6,7 +6,7 @@ import java.lang.annotation.Annotation; /** - * {@link ImportBeanDefinitionRegistrar} to enable {@link EnableOrientRepositories} annotation. + * {@link org.springframework.context.annotation.ImportBeanDefinitionRegistrar} to enable {@link EnableOrientRepositories} annotation. * * @author Dzmitry_Naskou */ diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/AbstractOrientQuery.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/AbstractOrientQuery.java index 3208274..478693d 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/AbstractOrientQuery.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/AbstractOrientQuery.java @@ -1,12 +1,10 @@ package org.springframework.data.orient.commons.repository.query; +import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.query.OSQLQuery; import org.springframework.data.orient.commons.core.OrientOperations; import org.springframework.data.orient.commons.repository.DetachMode; -import org.springframework.data.orient.commons.repository.query.OrientQueryExecution.CollectionExecution; -import org.springframework.data.orient.commons.repository.query.OrientQueryExecution.CountExecution; -import org.springframework.data.orient.commons.repository.query.OrientQueryExecution.PagedExecution; -import org.springframework.data.orient.commons.repository.query.OrientQueryExecution.SingleEntityExecution; +import org.springframework.data.orient.commons.repository.query.OrientQueryExecution.*; import org.springframework.data.repository.query.RepositoryQuery; /** @@ -14,16 +12,20 @@ */ public abstract class AbstractOrientQuery implements RepositoryQuery { - /** The query method. */ + /** + * The query method. + */ private final OrientQueryMethod method; - /** The object operations. */ + /** + * The object operations. + */ private final OrientOperations operations; /** * Instantiates a new {@link AbstractOrientQuery}. * - * @param method the query method + * @param method the query method * @param operations the orient operations */ public AbstractOrientQuery(OrientQueryMethod method, OrientOperations operations) { @@ -46,18 +48,18 @@ public OrientQueryMethod getQueryMethod() { public Object execute(Object[] parameters) { return doExecute(getExecution(), parameters); } - + /** * Do execute. * * @param execution the execution - * @param values the values + * @param values the values * @return the object */ protected Object doExecute(OrientQueryExecution execution, Object[] values) { return execution.execute(this, getDetachMode(), values); } - + /** * Creates the orient query. * @@ -68,7 +70,19 @@ protected Object doExecute(OrientQueryExecution execution, Object[] values) { protected OSQLQuery createQuery(Object[] values) { return applyFetchPlan(doCreateQuery(values)); } - + + /** + * Creates the orient command. + * + * @param values the parameters for query + * @return the OSQL query + */ + @SuppressWarnings("rawtypes") + protected OCommandSQL createCommand(Object[] values) { + return doCreateCommand(values); + } + + /** * Creates the count query. * @@ -79,7 +93,7 @@ protected OSQLQuery createQuery(Object[] values) { protected OSQLQuery createCountQuery(Object[] values) { return doCreateCountQuery(values); } - + /** * Do create query for specific source. * @@ -88,7 +102,7 @@ protected OSQLQuery createCountQuery(Object[] values) { */ @SuppressWarnings("rawtypes") protected abstract OSQLQuery doCreateQuery(Object[] values); - + /** * Do create count query for specific source. * @@ -97,7 +111,16 @@ protected OSQLQuery createCountQuery(Object[] values) { */ @SuppressWarnings("rawtypes") protected abstract OSQLQuery doCreateCountQuery(Object[] values); - + + /** + * Do create count query for specific source. + * + * @param values the parameters for query + * @return the OSQL Command + */ + + protected abstract OCommandSQL doCreateCommand(Object[] values); + /** * Gets the execution for query. * @@ -105,7 +128,7 @@ protected OSQLQuery createCountQuery(Object[] values) { */ protected OrientQueryExecution getExecution() { final OrientParameters parameters = method.getParameters(); - + if (method.isCollectionQuery()) { return new CollectionExecution(operations, parameters); } else if (isCountQuery()) { @@ -114,26 +137,30 @@ protected OrientQueryExecution getExecution() { return new PagedExecution(operations, parameters); } else if (method.isQueryForEntity()) { return new SingleEntityExecution(operations, parameters); - } - + } else if (isDeleteQuery()) { + return new DeleteExecution(operations, parameters); + } + throw new IllegalArgumentException(); } - + /** * Checks if is count query. * * @return true, if is count query */ protected abstract boolean isCountQuery(); - + + protected abstract boolean isDeleteQuery(); + @SuppressWarnings("rawtypes") private OSQLQuery applyFetchPlan(OSQLQuery query) { String fetchPlan = method.getFetchPlan(); - + if (fetchPlan != null) { query.setFetchPlan(fetchPlan); } - + return query; } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java index f534f33..befaed1 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java @@ -25,30 +25,31 @@ import java.util.List; import static org.jooq.impl.DSL.field; +import static org.jooq.impl.DSL.table; public class OrientQueryCreator extends AbstractQueryCreator { - + private static final Logger logger = LoggerFactory.getLogger(OrientQueryCreator.class); - + private final DSLContext context; - + private final PartTree tree; - + private final OrientParameterAccessor accessor; - + private final OrientQueryMethod method; - + private final ParamType paramType; - + private final Class domainClass; - + public OrientQueryCreator(PartTree tree, OrientQueryMethod method, OrientParameterAccessor parameters) { this(tree, method, parameters, ParamType.NAMED); } public OrientQueryCreator(PartTree tree, OrientQueryMethod method, OrientParameterAccessor parameters, ParamType paramType) { super(tree, parameters); - + this.method = method; this.context = DSL.using(SQLDialect.MYSQL); this.tree = tree; @@ -56,7 +57,7 @@ public OrientQueryCreator(PartTree tree, OrientQueryMethod method, OrientParamet this.paramType = paramType; this.domainClass = method.getEntityInformation().getJavaType(); } - + @Override protected Condition create(Part part, Iterator iterator) { return toCondition(part, iterator); @@ -71,17 +72,27 @@ protected Condition and(Part part, Condition base, Iterator iterator) { protected Condition or(Condition base, Condition criteria) { return base.or(criteria); } - + public boolean isCountQuery() { return tree.isCountProjection(); } + public boolean isDeleteQuery() { + return tree.isDelete(); + } + @Override protected String complete(Condition criteria, Sort sort) { Pageable pageable = accessor.getPageable(); - + + + if (tree.isDelete()) { + return completeDelete(criteria, sort); + } + + SelectSelectStep selectStep; - + if (isCountQuery()) { selectStep = context.selectCount(); } else if (tree.isDistinct()) { @@ -90,7 +101,7 @@ protected String complete(Condition criteria, Sort sort) { selectStep = context.select(); } - SelectConditionStep conditionStep = selectStep.from(QueryUtils.toSource(getSource())).where(criteria); + SelectConditionStep conditionStep = selectStep.from(QueryUtils.toSource(getSource())).where(criteria); SelectLimitStep limitStep = orderByIfRequired(conditionStep, pageable, sort); @@ -101,51 +112,76 @@ protected String complete(Condition criteria, Sort sort) { //Use inline parameters for paged queries String queryString = query.getSQL(ParamType.INLINED); logger.debug(queryString); - + return queryString; } - + + private String completeDelete(Condition criteria, Sort sort) { + return context.deleteFrom(table(QueryUtils.toSource(getSource()))).where(criteria).getSQL(ParamType.INDEXED); + + + } + protected Condition toCondition(Part part, Iterator iterator) { String property = part.getProperty().toDotPath(); Field field = field(property); - + switch (part.getType()) { - case AFTER: - case GREATER_THAN: return field.gt(iterator.next()); - case GREATER_THAN_EQUAL: return field.ge(iterator.next()); + case AFTER: + case GREATER_THAN: + return field.gt(iterator.next()); + case GREATER_THAN_EQUAL: + return field.ge(iterator.next()); case BEFORE: - case LESS_THAN: return field.lt(iterator.next()); - case LESS_THAN_EQUAL: return field.le(iterator.next()); - case BETWEEN: return field.between(iterator.next(), iterator.next()); - case IS_NULL: return field.isNull(); - case IS_NOT_NULL: return field.isNotNull(); - case IN: return field.in(toList(iterator)); - case NOT_IN: return field.notIn(toList(iterator)); - case LIKE: return lowerIfIgnoreCase(part, field, iterator); - case NOT_LIKE: return lowerIfIgnoreCase(part, field, iterator).not(); - case STARTING_WITH: return field.startsWith(iterator.next()); - case ENDING_WITH: return field.endsWith(iterator.next()); - case CONTAINING: return field.contains(iterator.next()); - case SIMPLE_PROPERTY: return field.eq(iterator.next()); - case NEGATING_SIMPLE_PROPERTY: return field.ne(iterator.next()); - case TRUE: return field.eq(true); - case FALSE: return field.eq(false); - default: throw new IllegalArgumentException("Unsupported keyword!"); + case LESS_THAN: + return field.lt(iterator.next()); + case LESS_THAN_EQUAL: + return field.le(iterator.next()); + case BETWEEN: + return field.between(iterator.next(), iterator.next()); + case IS_NULL: + return field.isNull(); + case IS_NOT_NULL: + return field.isNotNull(); + case IN: + return field.in(toList(iterator)); + case NOT_IN: + return field.notIn(toList(iterator)); + case LIKE: + return lowerIfIgnoreCase(part, field, iterator); + case NOT_LIKE: + return lowerIfIgnoreCase(part, field, iterator).not(); + case STARTING_WITH: + return field.startsWith(iterator.next()); + case ENDING_WITH: + return field.endsWith(iterator.next()); + case CONTAINING: + return field.contains(iterator.next()); + case SIMPLE_PROPERTY: + return field.eq(iterator.next()); + case NEGATING_SIMPLE_PROPERTY: + return field.ne(iterator.next()); + case TRUE: + return field.eq(true); + case FALSE: + return field.eq(false); + default: + throw new IllegalArgumentException("Unsupported keyword!"); } } - + protected OrientSource getSource() { OrientSource orientSource = accessor.getSource(); - + if (orientSource != null) { return orientSource; } - + Source source = findAnnotation(Source.class); if (source != null) { return new DefaultSource(source.type(), source.value()); } - + Cluster cluster = findAnnotation(Cluster.class); if (cluster != null) { return new DefaultSource(cluster.value()); @@ -153,50 +189,52 @@ protected OrientSource getSource() { return new DefaultSource(domainClass); } - + @SuppressWarnings("incomplete-switch") private Condition lowerIfIgnoreCase(Part part, Field field, Iterator iterator) { switch (part.shouldIgnoreCase()) { case ALWAYS: - case WHEN_POSSIBLE: return field.likeIgnoreCase(iterator.next().toString()); + case WHEN_POSSIBLE: + return field.likeIgnoreCase(iterator.next().toString()); } - + return field.like(iterator.next().toString()); } - + private List toList(Iterator iterator) { if (iterator == null || !iterator.hasNext()) { return Collections.emptyList(); } - + List list = new ArrayList(); while (iterator.hasNext()) { list.add(iterator.next()); } - + return list; } - + private List> toOrders(Sort sort) { List> orders = new ArrayList>(); - + for (Order order : sort) { - orders.add(field(order.getProperty()).sort(order.getDirection() == Direction.ASC ? SortOrder.ASC : SortOrder.DESC)); + orders.add(field(order.getProperty()).sort(order.getDirection() == Direction.ASC ? SortOrder.ASC : SortOrder.DESC)); } return orders; } - + private SelectLimitStep orderByIfRequired(SelectConditionStep conditionStep, Pageable pageable, Sort sort) { if (isCountQuery()) { return conditionStep; - } if (sort == null) { + } + if (sort == null) { return pageable == null ? conditionStep : conditionStep.and(field("@rid").gt(pageable.getOffset())); } else { return conditionStep.orderBy(toOrders(sort)); } } - + private Query limitIfPageable(SelectLimitStep limitStep, Pageable pageable, Sort sort) { if (pageable == null || isCountQuery()) { return limitStep; @@ -206,14 +244,14 @@ private Query limitIfPageable(SelectLimitStep limitStep, Pagea return limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); } } - + private A findAnnotation(Class annotationType) { A annotation = AnnotationUtils.findAnnotation(method.getMethod(), annotationType); - + if (annotation == null) { annotation = AnnotationUtils.findAnnotation(method.getRepositoryInterface(), annotationType); } - + return annotation; } } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryExecution.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryExecution.java index 34439b8..0e23340 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryExecution.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryExecution.java @@ -10,17 +10,20 @@ import java.util.List; /** - * Set of classes to contain query execution strategies. - * + * Set of classes to contain query execution strategies. + * * @author Dzmitry_Naskou - * */ public abstract class OrientQueryExecution { - /** The orient object template. */ + /** + * The orient object template. + */ protected final OrientOperations operations; - - /** The parameters. */ + + /** + * The parameters. + */ protected final OrientParameters parameters; public OrientQueryExecution(OrientOperations template, OrientParameters parameters) { @@ -28,30 +31,45 @@ public OrientQueryExecution(OrientOperations template, OrientParameters paramete this.operations = template; this.parameters = parameters; } - + /** * Executes the given {@link AbstractOrientQuery} with the given {@link Object[]} values. * - * @param query the orient query + * @param query the orient query * @param values the parameters values * @return the result */ public Object execute(AbstractOrientQuery query, DetachMode mode, Object[] values) { return doExecute(query, mode, values); } - + /** * Method to implement by executions. * - * @param query the orient query + * @param query the orient query * @param values the parameters values * @return the result */ protected abstract Object doExecute(AbstractOrientQuery query, DetachMode mode, Object[] values); - + + protected Object[] prepareParameters(OrientParameters parameters, Object[] values) { + int index = 0; + List params = new ArrayList<>(); + + for (OrientParameter parameter : parameters) { + if (parameter.isBindable()) { + params.add(values[index]); + } + + ++index; + } + + return params.toArray(); + } + /** * Executes the query to return a simple collection of entities. - * + * * @author Dzmitry_Naskou */ static class CollectionExecution extends OrientQueryExecution { @@ -136,7 +154,7 @@ static class PagedExecution extends OrientQueryExecution { /** * Instantiates a new {@link PagedExecution}. * - * @param template the orient object template + * @param template the orient object template * @param parameters the parameters */ public PagedExecution(OrientOperations template, OrientParameters parameters) { @@ -150,37 +168,34 @@ public PagedExecution(OrientOperations template, OrientParameters parameters) { @SuppressWarnings("unchecked") protected Object doExecute(AbstractOrientQuery query, DetachMode mode, Object[] values) { OrientParameterAccessor accessor = new OrientParametersParameterAccessor(parameters, values); - + final Object[] queryParams = prepareParameters(parameters, values); - + Long total = operations.count(query.createCountQuery(values), queryParams); - + Pageable pageable = accessor.getPageable(); - + List content; - + if (pageable != null && total > pageable.getOffset()) { content = operations.query(query.createQuery(values), mode, queryParams); } else { content = Collections.emptyList(); } - + return new PageImpl<>(content, pageable, total); } } - - protected Object[] prepareParameters(OrientParameters parameters, Object[] values) { - int index = 0; - List params = new ArrayList<>(); - - for (OrientParameter parameter : parameters) { - if (parameter.isBindable()) { - params.add(values[index]); - } - - ++index; + + static class DeleteExecution extends OrientQueryExecution { + + public DeleteExecution(OrientOperations template, OrientParameters parameters) { + super(template, parameters); + } + + @Override + protected Object doExecute(AbstractOrientQuery query, DetachMode mode, Object[] values) { + return operations.command(query.createCommand(values), prepareParameters(parameters, values)); } - - return params.toArray(); } } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/PartTreeOrientQuery.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/PartTreeOrientQuery.java index 3d54db3..99be70b 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/PartTreeOrientQuery.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/PartTreeOrientQuery.java @@ -1,5 +1,6 @@ package org.springframework.data.orient.commons.repository.query; +import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.query.OSQLQuery; import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import org.springframework.data.orient.commons.core.OrientOperations; @@ -12,13 +13,19 @@ */ public class PartTreeOrientQuery extends AbstractOrientQuery { - /** The domain class. */ + /** + * The domain class. + */ private final Class domainClass; - /** The tree. */ + /** + * The tree. + */ private final PartTree tree; - /** The parameters. */ + /** + * The parameters. + */ private final OrientParameters parameters; private final OrientQueryMethod method; @@ -26,7 +33,7 @@ public class PartTreeOrientQuery extends AbstractOrientQuery { /** * Instantiates a new {@link PartTreeOrientQuery} from given {@link OrientQueryMethod} and {@link OrientOperations}. * - * @param method the query method + * @param method the query method * @param operations the orient object template */ public PartTreeOrientQuery(OrientQueryMethod method, OrientOperations operations) { @@ -45,9 +52,9 @@ public PartTreeOrientQuery(OrientQueryMethod method, OrientOperations operations @SuppressWarnings("rawtypes") protected OSQLQuery doCreateQuery(Object[] values) { OrientParameterAccessor accessor = new OrientParametersParameterAccessor(parameters, values); - + OrientQueryCreator creator = new OrientQueryCreator(tree, method, accessor); - + return new OSQLSynchQuery(creator.createQuery()); } @@ -58,12 +65,21 @@ protected OSQLQuery doCreateQuery(Object[] values) { @SuppressWarnings("rawtypes") protected OSQLQuery doCreateCountQuery(Object[] values) { OrientParameterAccessor accessor = new OrientParametersParameterAccessor(parameters, values); - + OrientQueryCreator creator = new OrientCountQueryCreator(tree, method, accessor); - + return new OSQLSynchQuery(creator.createQuery()); } + @Override + protected OCommandSQL doCreateCommand(Object[] values) { + OrientParameterAccessor accessor = new OrientParametersParameterAccessor(parameters, values); + + OrientQueryCreator creator = new OrientQueryCreator(tree, method, accessor); + + return new OCommandSQL(creator.createQuery()); + } + /* (non-Javadoc) * @see org.springframework.data.orient.repository.object.query.AbstractOrientQuery#isCountQuery() */ @@ -71,4 +87,9 @@ protected OSQLQuery doCreateCountQuery(Object[] values) { protected boolean isCountQuery() { return tree.isCountProjection(); } + + @Override + protected boolean isDeleteQuery() { + return tree.isDelete(); + } } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java index 847bdcf..e29fa29 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java @@ -1,20 +1,23 @@ package org.springframework.data.orient.commons.repository.query; import com.orientechnologies.orient.core.record.impl.ODocument; +import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.query.OSQLQuery; import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import org.springframework.data.orient.commons.core.OrientOperations; public class StringBasedOrientQuery extends AbstractOrientQuery { - + private final String queryString; - + private final boolean isCountQuery; - + private final boolean isDeleteQuery; + public StringBasedOrientQuery(String query, OrientQueryMethod method, OrientOperations operations) { super(method, operations); this.queryString = query; this.isCountQuery = method.hasAnnotatedQuery() ? method.getQueryAnnotation().count() : false; + isDeleteQuery = query.toLowerCase().contains("delete"); } @Override @@ -22,7 +25,7 @@ public StringBasedOrientQuery(String query, OrientQueryMethod method, OrientOper protected OSQLQuery doCreateQuery(Object[] values) { OrientParameterAccessor accessor = new OrientParametersParameterAccessor(getQueryMethod().getParameters(), values); String sortedQuery = QueryUtils.applySorting(queryString, accessor.getSort()); - + return new OSQLSynchQuery(sortedQuery); } @@ -32,8 +35,21 @@ protected OSQLQuery doCreateCountQuery(Object[] values) { return new OSQLSynchQuery(queryString); } + @Override + protected OCommandSQL doCreateCommand(Object[] values) { + OrientParameterAccessor accessor = new OrientParametersParameterAccessor(getQueryMethod().getParameters(), values); + String sortedQuery = QueryUtils.applySorting(queryString, accessor.getSort()); + + return new OCommandSQL(sortedQuery); + } + @Override protected boolean isCountQuery() { return this.isCountQuery; } + + @Override + protected boolean isDeleteQuery() { + return isDeleteQuery; + } } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java index 17ed8d3..bf28d91 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java @@ -19,7 +19,8 @@ public class HelloConfiguration { public OrientObjectDatabaseFactory factory() { OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); - factory.setUrl("remote:127.0.0.1/GratefulDeadConcerts"); +// factory.setUrl("remote:127.0.0.1/GratefulDeadConcerts"); + factory.setUrl("memory:helloDb"); factory.setUsername("admin"); factory.setPassword("admin"); diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java index a061654..9c3f845 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.Id; import javax.persistence.Version; @@ -10,21 +11,21 @@ public class Person { @Id private String id; - + @Version @JsonIgnore private Long version; - + /** * Added to avoid a runtime error whereby the detachAll property is checked * for existence but not actually used. */ private String detachAll; - + private String firstName; - + private String lastName; - + private Integer age; public String getId() { diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java index 3797053..f8aa2ac 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java @@ -7,11 +7,14 @@ import java.util.List; public interface PersonRepository extends OrientObjectRepository { - + List findByFirstName(String firstName); - + @Query("select from person where lastName = ?") List findByLastName(String lastName); - + List findByAge(Integer age); + + // @Query("delete from person where age= ?") + Long deleteByAge(Integer age); } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java index d2c39f8..7f5968d 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java @@ -16,24 +16,29 @@ public class PersonController { @Autowired private PersonRepository repository; - + @RequestMapping(method = RequestMethod.GET) public List findAllPersons() { return repository.findAll(); } - + @RequestMapping("/findByFirstName") public List findByFirstName(@RequestParam String firstName) { return repository.findByFirstName(firstName); } - + @RequestMapping("/findByLastName") public List findByLastName(@RequestParam String lastName) { return repository.findByLastName(lastName); } - + @RequestMapping("/findByAge") public List findByAge(@RequestParam Integer age) { return repository.findByAge(age); } + + @RequestMapping("/deleteByAge") + public Long deleteByAge(@RequestParam Integer age) { + return repository.deleteByAge(age); + } } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 4d30f2e..18fc708 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -132,7 +132,7 @@ org.apache.maven.plugins maven-surefire-plugin - true + From f1672986edce577dbb78672d11cb73b08ef67716 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 1 Sep 2016 18:18:46 +0200 Subject: [PATCH 16/41] moved to junit, new tests for delete support on object repository --- pom.xml | 29 ++++--- .../core/AbstractOrientDatabaseFactory.java | 8 ++ .../core/AbstractOrientOperations.java | 2 + .../commons/core/OrientDatabaseFactory.java | 2 + .../config/OrientPackageScannerTest.java | 9 +- .../OrientDbObjectTestConfiguration.java | 6 +- .../object/context/ContextEnviromentTest.java | 13 +-- .../object/repository/PersonRepository.java | 12 ++- .../repository/PersonRepositoryTest.java | 83 ++++++++++--------- .../EmployeeClusteredRepositoryTest.java | 32 +++---- .../object/util/OrientOperationUtilTest.java | 20 ++--- .../src/test/resources/logback.xml | 4 +- .../spring-boot-orientdb-shiro/pom.xml | 2 +- .../sample/shiro/OrientDbConfiguration.java | 55 ++++++++++-- .../sample/shiro/rest/UserControllerTest.java | 14 ++-- 15 files changed, 184 insertions(+), 107 deletions(-) diff --git a/pom.xml b/pom.xml index a0aa7ac..571cc16 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 1.7.13 1.1.3 - 2.2.7 + 2.2.8 1.8.7 4.2.4.RELEASE 1.11.2.RELEASE @@ -362,10 +362,11 @@ ${junit.version} - org.testng - testng - ${testng.version} + org.assertj + assertj-core + 2.5.0 + org.springframework spring-test @@ -420,9 +421,21 @@ + + + + + + + + + junit + junit + test + - org.testng - testng + org.assertj + assertj-core test @@ -496,10 +509,6 @@ org.apache.maven.plugins maven-surefire-plugin 2.18 - - methods - 5 - org.apache.maven.plugins diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java index 2a93fbd..35f7c2c 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java @@ -88,6 +88,14 @@ public ODatabase db() { return db; } + + @Override + public void dropDatabase() { + ODatabaseInternal database = newDatabase(); + database.open(username, password); + database.drop(); + } + protected void createDatabase(ODatabase db) { if (autoCreate) { if (!db.exists()) { diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java index 4a83154..6590ded 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java @@ -23,6 +23,7 @@ import com.orientechnologies.orient.core.storage.ORecordMetadata; import com.orientechnologies.orient.core.storage.OStorage; import com.orientechnologies.orient.core.tx.OTransaction; +import org.jooq.SQL; import org.springframework.data.orient.commons.repository.DetachMode; import java.io.IOException; @@ -581,6 +582,7 @@ public RET command(OCommandRequest command) { @Override public RET command(OCommandSQL command, Object... args) { + return dbf.db().command(command).execute(args); } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java index b59045d..4363c9c 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java @@ -38,4 +38,6 @@ public interface OrientDatabaseFactory { int getMaxPoolSize(); void setMaxPoolSize(int maxPoolSize); + + void dropDatabase(); } diff --git a/spring-data-orientdb-commons/src/test/java/org/springframework/data/orient/commons/repository/config/OrientPackageScannerTest.java b/spring-data-orientdb-commons/src/test/java/org/springframework/data/orient/commons/repository/config/OrientPackageScannerTest.java index ffb676d..23191f9 100644 --- a/spring-data-orientdb-commons/src/test/java/org/springframework/data/orient/commons/repository/config/OrientPackageScannerTest.java +++ b/spring-data-orientdb-commons/src/test/java/org/springframework/data/orient/commons/repository/config/OrientPackageScannerTest.java @@ -1,12 +1,15 @@ package org.springframework.data.orient.commons.repository.config; -import org.springframework.data.orient.commons.repository.config.scanner.test.*; -import org.testng.annotations.Test; +import org.junit.Test; +import org.springframework.data.orient.commons.repository.config.scanner.test.EntitiesMarker; +import org.springframework.data.orient.commons.repository.config.scanner.test.SimpleEdgeEntity; +import org.springframework.data.orient.commons.repository.config.scanner.test.SimpleVertexEntity; import java.util.HashSet; import java.util.Set; -import static org.testng.Assert.assertEquals; +import static org.junit.Assert.assertEquals; + /** * @author saljuama diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java index 2f3c802..238426c 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java @@ -19,7 +19,8 @@ @Configuration @EnableTransactionManagement -@EnableOrientRepositories(basePackages = "org.springframework.data.orient.object", repositoryFactoryBeanClass = OrientObjectRepositoryFactoryBean.class) +@EnableOrientRepositories(basePackages = "org.springframework.data.orient.object", + repositoryFactoryBeanClass = OrientObjectRepositoryFactoryBean.class) public class OrientDbObjectTestConfiguration { public static final String EMPLOYEE_TMP_CLUSTER = "employee_tmp"; @@ -33,7 +34,7 @@ public class OrientDbObjectTestConfiguration { @Bean public OrientObjectDatabaseFactory factory() { - OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); + OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); //factory.setUrl("plocal:target/spring-data-orientdb-db"); factory.setUrl("memory:spring-data-orientdb-db"); @@ -71,5 +72,6 @@ public void registerEntities() { int id = db.addCluster(EMPLOYEE_HISTORY_CLUSTER); db.getMetadata().getSchema().getClass(Employee.class).addClusterId(id); } + } } diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/context/ContextEnviromentTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/context/ContextEnviromentTest.java index 8bdc97f..e1acc64 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/context/ContextEnviromentTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/context/ContextEnviromentTest.java @@ -1,5 +1,7 @@ package org.springframework.data.orient.object.context; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.aop.SpringProxy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -8,17 +10,16 @@ import org.springframework.data.orient.object.OrientObjectDatabaseFactory; import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.testng.annotations.Test; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; -@Configuration @EnableTransactionManagement @ContextConfiguration(classes = OrientDbObjectTestConfiguration.class) -public class ContextEnviromentTest extends AbstractTestNGSpringContextTests{ +@RunWith(SpringJUnit4ClassRunner.class) +public class ContextEnviromentTest { @Autowired ApplicationContext context; diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java index e6dced4..221f022 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java @@ -14,9 +14,9 @@ public interface PersonRepository extends OrientObjectRepository { @Query("select from person where firstName = ?") List findByFirstName(String firstName); - + Page findByFirstName(String firstName, Pageable pageable); - + List findByLastName(String lastName); List findByLastNameLike(String lastName); @@ -26,7 +26,7 @@ public interface PersonRepository extends OrientObjectRepository { List findByFirstNameOrLastName(String firstName, String lastName); List findByFirstNameLike(String string); - + List findByFirstNameStartsWith(String firstName); Long countByFirstName(String firstName); @@ -40,4 +40,10 @@ public interface PersonRepository extends OrientObjectRepository { List findByActiveIsTrue(); List findByActiveIsFalse(); + + Long deleteByActiveIsTrue(); + + Long deleteByActiveIsFalse(); + + Long deleteByActive(Boolean active); } diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java index 67cf5dc..734dd22 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java @@ -1,7 +1,9 @@ package org.springframework.data.orient.object.repository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.orient.object.OrientDbObjectTestConfiguration; @@ -10,65 +12,58 @@ import org.springframework.data.orient.object.domain.Address; import org.springframework.data.orient.object.domain.Person; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List; -import static org.testng.Assert.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.*; -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@Rollback -@TestExecutionListeners( - inheritListeners = false, - listeners = {DependencyInjectionTestExecutionListener.class}) -@ContextConfiguration(classes = OrientDbObjectTestConfiguration.class) -@Transactional -public class PersonRepositoryTest extends AbstractTestNGSpringContextTests { - private static final Logger logger = LoggerFactory.getLogger(PersonRepositoryTest.class); +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {OrientDbObjectTestConfiguration.class}) +public class PersonRepositoryTest { + + @Autowired + OrientObjectOperations operations; @Autowired PersonRepository repository; - + @Autowired OrientObjectDatabaseFactory factory; - - @Autowired - OrientObjectOperations operations; - - @BeforeClass - public void before() { + + @Before + public void setUp() { + + operations.command("delete from Address"); + operations.command("delete from Person"); + Address esenina = operations.command("insert into Address (country, city, street) values ('Belarus', 'Minsk', 'Esenina')"); - + operations.command("insert into Person (firstName, lastName, active, address) values (?, ?, ?, ?)", "Dzmitry", "Naskou", true, esenina); operations.command("insert into Person (firstName, lastName, active) values ('Koby', 'Eliot', true)"); operations.command("insert into Person (firstName, lastName, active) values ('Ronny', 'Carlisle', true)"); operations.command("insert into Person (firstName, lastName, active) values ('Jameson', 'Matthew', true)"); operations.command("insert into Person (firstName, lastName, active) values ('Roydon', 'Brenden', false)"); } - + + @Test public void repositoryAutowiring() { - assertNotNull(repository); + Assert.assertNotNull(repository); } - + @Test public void savePerson() { Person person = new Person(); person.setFirstName("Jay"); person.setLastName("Miner"); - + String rid = repository.save(person).getRid(); - + Person result = repository.findOne(rid); - + assertEquals(result.getFirstName(), person.getFirstName()); assertEquals(result.getLastName(), person.getLastName()); } @@ -146,16 +141,12 @@ public void findByFirstNameOrLastName() { @Test public void findByActiveIsTrue() { - for (Person person : repository.findByActiveIsTrue()) { - assertTrue(person.getActive()); - } + assertThat(repository.findByActiveIsTrue()).hasSize(4); } @Test public void findByActiveIsFalse() { - for (Person person : repository.findByActiveIsFalse()) { - assertFalse(person.getActive()); - } + assertThat(repository.findByActiveIsFalse()).hasSize(1); } @Test @@ -168,4 +159,16 @@ public void findByCityTest() { assertEquals(person.getAddress().getCity(), "Minsk"); } } + + + @Test + public void deleteByActive() { + + assertThat(repository.deleteByActive(false)).isEqualTo(1); + assertThat(repository.deleteByActive(true)).isEqualTo(4); + + + } + + } diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java index 399e353..c9c2a8b 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/cluster/EmployeeClusteredRepositoryTest.java @@ -3,8 +3,9 @@ import com.orientechnologies.orient.core.id.ORecordId; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -16,26 +17,22 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.transaction.annotation.Transactional; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.springframework.data.orient.object.OrientDbObjectTestConfiguration.EMPLOYEE_TMP_CLUSTER; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @Rollback @ContextConfiguration(classes = OrientDbObjectTestConfiguration.class) @Transactional -public class EmployeeClusteredRepositoryTest extends AbstractTestNGSpringContextTests { +public class EmployeeClusteredRepositoryTest extends AbstractJUnit4SpringContextTests { - private static final Logger logger = LoggerFactory.getLogger(EmployeeClusteredRepositoryTest.class); @Autowired OrientObjectDatabaseFactory dbf; @@ -49,8 +46,10 @@ public class EmployeeClusteredRepositoryTest extends AbstractTestNGSpringContext @Autowired OrientObjectOperations operations; - @BeforeClass + @Before public void before() { + operations.command("delete from employee"); + operations.command("insert into cluster:employee (firstName, lastName, active) values ('Dzmitry', 'Naskou', true)"); operations.command("insert into cluster:employee (firstName, lastName, active) values ('Koby', 'Eliot', true)"); operations.command("insert into cluster:employee_tmp (firstName, lastName, active) values ('Ronny', 'Carlisle', true)"); @@ -60,7 +59,8 @@ public void before() { @Test public void findAll() { - logger.debug("Employees: {}", repository.findAll()); + + logger.debug("Employees: " + repository.findAll()); } @Test @@ -90,7 +90,7 @@ public void saveEmployeeToClusterTest() { @Test public void findAllByCluster() { - logger.debug("Employees: {}", repository.findAll(EMPLOYEE_TMP_CLUSTER)); + logger.debug("Employees: " + repository.findAll(EMPLOYEE_TMP_CLUSTER)); } @Test @@ -98,7 +98,7 @@ public void checkClasses() { OObjectDatabaseTx db = dbf.openDatabase(); for (OClass c : db.getMetadata().getSchema().getClasses()) { - logger.debug("Class: {}", c); + logger.debug("Class: " + c); } db.close(); @@ -120,7 +120,7 @@ public void getEmployeeClusters() { OObjectDatabaseTx db = dbf.openDatabase(); for (int i : db.getMetadata().getSchema().getClass(Employee.class).getClusterIds()) { - logger.debug("Cluster ID: {}", i); + logger.debug("Cluster ID: " + i); } db.close(); @@ -159,7 +159,7 @@ public void findByIds() { @Test public void findByLastNameTest() { - logger.debug("Employee: {}", repository.findByLastName("Naskou")); + logger.debug("Employee: " + repository.findByLastName("Naskou")); } @Test diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java index 7d3a1eb..43d8dad 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/util/OrientOperationUtilTest.java @@ -1,26 +1,22 @@ package org.springframework.data.orient.object.util; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; import org.springframework.data.orient.object.OrientDbObjectTestConfiguration; import org.springframework.data.orient.object.OrientObjectDatabaseFactory; import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.data.orient.object.domain.Address; import org.springframework.data.orient.object.domain.Employee; -import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -@Configuration -@EnableTransactionManagement -@Rollback @ContextConfiguration(classes = OrientDbObjectTestConfiguration.class) -public class OrientOperationUtilTest extends AbstractTestNGSpringContextTests { +@RunWith(SpringJUnit4ClassRunner.class) +public class OrientOperationUtilTest { @Autowired OrientObjectOperations template; @@ -28,7 +24,7 @@ public class OrientOperationUtilTest extends AbstractTestNGSpringContextTests { @Autowired OrientObjectDatabaseFactory factory; - @BeforeClass + @Before public void before() { try (OObjectDatabaseTx db = factory.openDatabase()) { db.getEntityManager().registerEntityClass(Employee.class); diff --git a/spring-data-orientdb-object/src/test/resources/logback.xml b/spring-data-orientdb-object/src/test/resources/logback.xml index 41a4d21..2485041 100644 --- a/spring-data-orientdb-object/src/test/resources/logback.xml +++ b/spring-data-orientdb-object/src/test/resources/logback.xml @@ -22,8 +22,8 @@ --> - + - + diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 18fc708..4d30f2e 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -132,7 +132,7 @@ org.apache.maven.plugins maven-surefire-plugin - + true diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/OrientDbConfiguration.java b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/OrientDbConfiguration.java index 24eae92..6afd853 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/OrientDbConfiguration.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/main/java/org/springframework/boot/orient/sample/shiro/OrientDbConfiguration.java @@ -2,8 +2,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * + * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -13,24 +13,67 @@ package org.springframework.boot.orient.sample.shiro; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; +import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; +import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.orient.commons.core.OrientTransactionManager; import org.springframework.data.orient.commons.repository.config.EnableOrientRepositories; import org.springframework.data.orient.object.OrientObjectDatabaseFactory; +import org.springframework.data.orient.object.OrientObjectOperations; +import org.springframework.data.orient.object.OrientObjectTemplate; import org.springframework.data.orient.object.repository.support.OrientObjectRepositoryFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; @Configuration -@EnableOrientRepositories(basePackages = "org.springframework.boot.orient.sample.shiro.repository", repositoryFactoryBeanClass = OrientObjectRepositoryFactoryBean.class) +@EnableTransactionManagement +@EnableOrientRepositories(basePackages = "org.springframework.boot.orient.sample.shiro.repository", + repositoryFactoryBeanClass = OrientObjectRepositoryFactoryBean.class) public class OrientDbConfiguration { - @Autowired - private OrientObjectDatabaseFactory factory; +// @Autowired +// private OrientObjectDatabaseFactory factory; + + + @Bean + public OrientObjectDatabaseFactory factory() { + OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); + factory.setUrl("memory:spring-data-orientdb-db"); + factory.setUsername("admin"); + factory.setPassword("admin"); + + return factory; + } @PostConstruct @Transactional public void registerEntities() { - factory.db().getEntityManager().registerEntityClasses("org.springframework.boot.orient.sample.shiro.model"); + factory().db().getEntityManager().registerEntityClasses("org.springframework.boot.orient.sample.shiro.model"); + + + } + + @Bean + public OrientTransactionManager transactionManager() { + return new OrientTransactionManager(factory()); } + + + @Bean + public OrientObjectOperations objectTemplate() { + return new OrientObjectTemplate(factory()); + } + + + @Bean + public EmbeddedServletContainerFactory servletContainer() { + TomcatEmbeddedServletContainerFactory factory = + new TomcatEmbeddedServletContainerFactory(); + return factory; + } + } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java index f63eff3..3f8a37c 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java @@ -16,6 +16,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.credential.DefaultPasswordService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.orient.sample.shiro.Application; import org.springframework.boot.orient.sample.shiro.OrientDbConfiguration; @@ -31,23 +34,22 @@ import org.springframework.boot.test.TestRestTemplate; import org.springframework.http.*; import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.springframework.test.context.web.WebAppConfiguration; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import java.util.Arrays; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; -import static org.testng.AssertJUnit.assertEquals; +import static org.junit.Assert.assertEquals; @SpringApplicationConfiguration(classes = {Application.class, OrientDbConfiguration.class, ShiroConfiguration.class}) @WebAppConfiguration @IntegrationTest @TestExecutionListeners(inheritListeners = false, listeners = {DependencyInjectionTestExecutionListener.class}) -public class UserControllerTest extends AbstractTestNGSpringContextTests { +@RunWith(SpringJUnit4ClassRunner.class) +public class UserControllerTest { private final String BASE_URL = "http://localhost:8080/users"; private final String USER_NAME = "Paulo Pires"; @@ -62,7 +64,7 @@ public class UserControllerTest extends AbstractTestNGSpringContextTests { @Autowired private PermissionRepository permissionRepo; - @BeforeClass + @Before public void setUp() { // clean-up users, roles and permissions userRepo.deleteAll(); From d5cf6ecfab43a9f6446190283c4f25a4661b00d6 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Fri, 2 Sep 2016 10:58:39 +0200 Subject: [PATCH 17/41] adds example countBy method with annotated query to PersonRepository refs https://github.com/orientechnologies/spring-data-orientdb/issues/58 --- .../orient/object/repository/PersonRepository.java | 9 ++++++++- .../object/repository/PersonRepositoryTest.java | 14 +++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java index 221f022..36a152d 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java @@ -31,6 +31,11 @@ public interface PersonRepository extends OrientObjectRepository { Long countByFirstName(String firstName); + Long countByActive(Boolean active); + + @Query(value = "select count(*) from person where firstName = ? and active = ?", count = true) + Long countByFirstNameAndActive(String firstName, Boolean active); + @Detach(DetachMode.ENTITY) List findByAddress_City(String city); @@ -46,4 +51,6 @@ public interface PersonRepository extends OrientObjectRepository { Long deleteByActiveIsFalse(); Long deleteByActive(Boolean active); -} + + + } diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java index 734dd22..e7c58d2 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java @@ -11,7 +11,6 @@ import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.data.orient.object.domain.Address; import org.springframework.data.orient.object.domain.Person; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -163,12 +162,21 @@ public void findByCityTest() { @Test public void deleteByActive() { - assertThat(repository.deleteByActive(false)).isEqualTo(1); assertThat(repository.deleteByActive(true)).isEqualTo(4); + } - + @Test + public void countByActive() { + assertThat(repository.countByActive(false)).isEqualTo(1); + assertThat(repository.countByActive(true)).isEqualTo(4); } + @Test + public void countByFirstNameAndActive() { + + assertThat(repository.countByFirstNameAndActive("Dzmitry", true)).isEqualTo(1); + + } } From 73a3bdf00f38e4ec54d0fbfb639140c457287661 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Fri, 16 Sep 2016 17:12:34 +0200 Subject: [PATCH 18/41] - orientDB version to 2.2.10 refs https://github.com/orientechnologies/spring-data-orientdb/issues/59 refs https://github.com/orientechnologies/spring-data-orientdb/issues/54 --- README.md | 33 ++- pom.xml | 2 +- .../core/AbstractOrientOperations.java | 2 - .../commons/repository/OrientRepository.java | 1 + .../commons/repository/query/JooqUtils.java | 2 +- .../repository/query/OrientQueryCreator.java | 16 +- .../query/StringBasedOrientQuery.java | 1 + .../support/SimpleOrientRepository.java | 1 + .../orient/document/repository/Address.java | 51 ++++ .../orient/document/repository/Person.java | 61 ++++ .../document/repository/PersonRepository.java | 55 ++++ .../object/OrientObjectDatabaseFactory.java | 2 - .../orient/object/OrientObjectOperations.java | 1 + .../orient/object/OrientObjectTemplate.java | 279 +----------------- .../repository/OrientObjectRepository.java | 6 +- .../OrientObjectRepositoryFactory.java | 2 +- .../OrientObjectRepositoryFactoryBean.java | 12 +- .../support/SimpleOrientObjectRepository.java | 10 +- .../object/repository/PersonRepository.java | 12 +- .../repository/PersonRepositoryTest.java | 80 +++-- .../src/test/resources/logback.xml | 4 +- .../boot/orientdb/hello/data/Person.java | 4 +- .../hello/repository/PersonRepository.java | 7 +- 23 files changed, 304 insertions(+), 340 deletions(-) create mode 100644 spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Address.java create mode 100644 spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Person.java create mode 100644 spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/PersonRepository.java diff --git a/README.md b/README.md index 49b494f..7f94e44 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Spring Data OrientDB -==================== +# Spring Data OrientDB The primary goal of the [Spring Data](http://projects.spring.io/) project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services. @@ -11,47 +10,57 @@ The document module is based on the [Spring Data MongoDB](http://projects.spring To include OrientDB Spring Data in your Java project via Maven, put one of the snippets below in your pom.xml or build.gradle -### Graph API +## Object API -Maven: +### Dependency management + +Maven ```xml com.orientechnologies - spring-data-orientdb-graph + spring-data-orientdb-object 0.12 ``` Gradle: ```groovy - group: 'com.orientechnologies', name: 'spring-data-orientdb-graph', version: '0.12' + group: 'com.orientechnologies', name: 'spring-data-orientdb-object', version: '0.12' ``` +### Example -### Document API +To + + +## Graph API + +Maven: ```xml com.orientechnologies - spring-data-orientdb-document + spring-data-orientdb-graph 0.12 ``` Gradle: ```groovy - group: 'com.orientechnologies', name: 'spring-data-orientdb-document', version: '0.12' + group: 'com.orientechnologies', name: 'spring-data-orientdb-graph', version: '0.12' ``` -### Object API + +### Document API ```xml com.orientechnologies - spring-data-orientdb-object + spring-data-orientdb-document 0.12 ``` Gradle: ```groovy - group: 'com.orientechnologies', name: 'spring-data-orientdb-object', version: '0.12' + group: 'com.orientechnologies', name: 'spring-data-orientdb-document', version: '0.12' ``` + diff --git a/pom.xml b/pom.xml index 571cc16..8055fa9 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 1.7.13 1.1.3 - 2.2.8 + 2.2.10 1.8.7 4.2.4.RELEASE 1.11.2.RELEASE diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java index 6590ded..d4744f7 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java @@ -23,7 +23,6 @@ import com.orientechnologies.orient.core.storage.ORecordMetadata; import com.orientechnologies.orient.core.storage.OStorage; import com.orientechnologies.orient.core.tx.OTransaction; -import org.jooq.SQL; import org.springframework.data.orient.commons.repository.DetachMode; import java.io.IOException; @@ -33,7 +32,6 @@ import java.util.concurrent.Callable; public abstract class AbstractOrientOperations implements OrientOperations { - // private static final Logger logger = LoggerFactory.getLogger(AbstractOrientOperations.class); protected final OrientDatabaseFactory dbf; diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/OrientRepository.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/OrientRepository.java index 1472451..795600d 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/OrientRepository.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/OrientRepository.java @@ -1,6 +1,7 @@ package org.springframework.data.orient.commons.repository; import org.springframework.data.domain.Sort; +import org.springframework.data.orient.commons.repository.annotation.Detach; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.PagingAndSortingRepository; diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/JooqUtils.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/JooqUtils.java index b1ce880..305fe2f 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/JooqUtils.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/JooqUtils.java @@ -9,7 +9,7 @@ public class JooqUtils { public static DSLContext context() { - return DSL.using(SQLDialect.MYSQL); + return DSL.using(SQLDialect.DEFAULT); } public static SelectJoinStep from(String source) { diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java index befaed1..5927823 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryCreator.java @@ -228,11 +228,18 @@ private SelectLimitStep orderByIfRequired(SelectConditionStep< if (isCountQuery()) { return conditionStep; } + + if (sort == null) { return pageable == null ? conditionStep : conditionStep.and(field("@rid").gt(pageable.getOffset())); - } else { - return conditionStep.orderBy(toOrders(sort)); } + + +// if (sort == null) { +// return conditionStep; +// } + return conditionStep.orderBy(toOrders(sort)); + } private Query limitIfPageable(SelectLimitStep limitStep, Pageable pageable, Sort sort) { @@ -240,9 +247,10 @@ private Query limitIfPageable(SelectLimitStep limitStep, Pagea return limitStep; } else if (sort == null) { return limitStep.limit(pageable.getPageSize()); - } else { - return limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); } + + return limitStep.limit(pageable.getPageSize()).offset(pageable.getOffset()); + } private A findAnnotation(Class annotationType) { diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java index e29fa29..c56eda8 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/StringBasedOrientQuery.java @@ -18,6 +18,7 @@ public StringBasedOrientQuery(String query, OrientQueryMethod method, OrientOper this.queryString = query; this.isCountQuery = method.hasAnnotatedQuery() ? method.getQueryAnnotation().count() : false; isDeleteQuery = query.toLowerCase().contains("delete"); + } @Override diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/SimpleOrientRepository.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/SimpleOrientRepository.java index a2aa3aa..122a9b9 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/SimpleOrientRepository.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/SimpleOrientRepository.java @@ -339,6 +339,7 @@ private OSQLQuery getQuery(Sort sort) { * @return the query */ private OSQLQuery getQuery(String source, Sort sort) { + Query query = DSL.using(SQLDialect.MYSQL).select().from(source).orderBy(QueryUtils.toOrders(sort)); return new OSQLSynchQuery(query.getSQL(ParamType.INLINED)); diff --git a/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Address.java b/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Address.java new file mode 100644 index 0000000..a7cbaec --- /dev/null +++ b/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Address.java @@ -0,0 +1,51 @@ +package org.springframework.data.orient.document.repository; + +import com.orientechnologies.orient.core.annotation.OId; +import com.orientechnologies.orient.core.annotation.OVersion; + +public class Address { + + @OId + private String id; + + @OVersion + private Long version; + + private String country; + + private String city; + + private String street; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } +} diff --git a/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Person.java b/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Person.java new file mode 100644 index 0000000..744c8ee --- /dev/null +++ b/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/Person.java @@ -0,0 +1,61 @@ +package org.springframework.data.orient.document.repository; + +import com.orientechnologies.orient.core.annotation.OId; +import com.orientechnologies.orient.core.annotation.OVersion; + +public class Person { + + @OId + private String rid; + + @OVersion + private Long version; + + private String firstName; + + private String lastName; + + private Address address; + + private Boolean active; + + public String getRid() { + return rid; + } + + public void setRid(String rid) { + this.rid = rid; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } +} diff --git a/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/PersonRepository.java b/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/PersonRepository.java new file mode 100644 index 0000000..bafe5bb --- /dev/null +++ b/spring-data-orientdb-document/src/test/java/org/springframework/data/orient/document/repository/PersonRepository.java @@ -0,0 +1,55 @@ +package org.springframework.data.orient.document.repository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.orient.commons.repository.DetachMode; +import org.springframework.data.orient.commons.repository.annotation.Detach; +import org.springframework.data.orient.commons.repository.annotation.FetchPlan; +import org.springframework.data.orient.commons.repository.annotation.Query; + +import java.util.List; + +public interface PersonRepository extends OrientDocumentRepository { + + @Query("select from person where firstName = ?") + List findByFirstName(String firstName); + + Page findByFirstName(String firstName, Pageable pageable); + + List findByLastName(String lastName); + + List findByLastNameLike(String lastName); + + List findByFirstNameAndLastName(String firstName, String lastName); + + List findByFirstNameOrLastName(String firstName, String lastName); + + List findByFirstNameLike(String string); + + List findByFirstNameStartsWith(String firstName); + + Long countByFirstName(String firstName); + + Long countByActive(Boolean active); + + @Query(value = "select count(*) from person where firstName = ? and active = ?", count = true) + Long countByFirstNameAndActive(String firstName, Boolean active); + + @Detach(DetachMode.ENTITY) + List findByAddress_City(String city); + + @FetchPlan("*:-1") + List findByAddress_Country(String city); + + List findByActiveIsTrue(); + + List findByActiveIsFalse(); + + Long deleteByActiveIsTrue(); + + Long deleteByActiveIsFalse(); + + Long deleteByActive(Boolean active); + + +} diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java index 986ed15..f2ec0c7 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java @@ -22,8 +22,6 @@ public class OrientObjectDatabaseFactory extends AbstractOrientDatabaseFactory { + OObjectDatabaseTx getObjectDatabase(); } diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectTemplate.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectTemplate.java index 1987609..2f9f6e4 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectTemplate.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectTemplate.java @@ -20,26 +20,26 @@ public OrientObjectTemplate(OrientObjectDatabaseFactory dbf) { @Override public OObjectDatabaseTx getObjectDatabase() { - return (OObjectDatabaseTx)dbf.db(); + return (OObjectDatabaseTx) dbf.db(); } @Override public String getRid(Object entity) { Class clazz = entity.getClass(); - while(clazz != Object.class){ - for(Field field : clazz.getDeclaredFields()){ + while (clazz != Object.class) { + for (Field field : clazz.getDeclaredFields()) { OId ridAnnotation = field.getAnnotation(OId.class); - if(ridAnnotation != null){ + if (ridAnnotation != null) { field.setAccessible(true); - try{ + try { Object rid = field.get(entity); - if(rid == null) { + if (rid == null) { Method method = clazz.getDeclaredMethod(getterName(field.getName())); rid = method.invoke(entity); } - return rid != null ? rid.toString() : null; + return rid != null ? rid.toString() : null; } catch (IllegalAccessException | IllegalArgumentException - | NoSuchMethodException | InvocationTargetException ex){ + | NoSuchMethodException | InvocationTargetException ex) { throw new RuntimeException(ex); } } @@ -65,7 +65,7 @@ public > RET detach(RET entities) { result.add(db.detach(entity, true)); } - return (RET)result; + return (RET) result; } @Override @@ -86,271 +86,14 @@ public > RET detachAll(RET entities) { @Override @SuppressWarnings("unchecked") public RET detach(RET entity) { - return (RET)getObjectDatabase().detach(entity, true); + return (RET) getObjectDatabase().detach(entity, true); } @Override @SuppressWarnings("unchecked") public RET detachAll(RET entity) { - return (RET)getObjectDatabase().detachAll(entity, true); - } - -/** - @Override - public > RET query(OQuery query, DetachMode detachMode, Object... args) { - RET result = query(query, args); - - switch (detachMode) { - case ENTITY: - return detach(result); - case ALL: - return detachAll(result); - case NONE: - } - - return result; - } - - @Override - @SuppressWarnings("unchecked") - public > RET detach(RET list) { - final OObjectDatabaseTx db = getObjectDatabase(); - - List pojos = new ArrayList<>(list.size()); - - for (Object object : list) { - pojos.add(db.detach(object, true)); - } - - return (RET) pojos; - } - - @Override - @SuppressWarnings("unchecked") - public > RET detachAll(RET list) { - final OObjectDatabaseTx db = getObjectDatabase(); - - List pojos = new ArrayList<>(list.size()); - - for (Object object : list) { - pojos.add(db.detachAll(object, true)); - } - - return (RET) pojos; - } - - @Override - public OObjectIteratorClass browseClass(Class iClusterClass) { - return getObjectDatabase().browseClass(iClusterClass); - } - - @Override - public OObjectIteratorClass browseClass(Class iClusterClass, boolean iPolymorphic) { - return getObjectDatabase().browseClass(iClusterClass, iPolymorphic); - } - - @Override - public OObjectIteratorClass browseClass(String iClassName) { - return getObjectDatabase().browseClass(iClassName); - } - - @Override - public OObjectIteratorClass browseClass(String iClassName, boolean iPolymorphic) { - return getObjectDatabase().browseClass(iClassName, iPolymorphic); - } - - @Override - public ODatabaseInternal getDatabaseOwner() { - return getObjectDatabase().getDatabaseOwner(); - } - - @Override - public ODatabaseInternal setDatabaseOwner(ODatabaseInternal iOwner) { - return getObjectDatabase().setDatabaseOwner(iOwner); - } - - @Override - public OObjectIteratorCluster browseCluster(String iClusterName) { - return getObjectDatabase().browseCluster(iClusterName); - } - - @Override - public V callInLock(Callable iCallable, boolean iExclusiveLock) { - return getObjectDatabase().callInLock(iCallable, iExclusiveLock); - } - - @Override - public ODatabasePojoAbstract setRetainObjects(boolean iValue) { - return getObjectDatabase().setRetainObjects(iValue); - } - - @Override - public void attach(Object iPojo) { - getObjectDatabase().attach(iPojo); - } - - @Override - public RET attachAndSave(Object iPojo) { - return getObjectDatabase().attachAndSave(iPojo); - } - - @Override - public boolean isRetainObjects() { - return getObjectDatabase().isRetainObjects(); - } - - @Override - public RET detach(Object iPojo) { - return getObjectDatabase().detach(iPojo); - } - - @Override - public RET detach(Object iPojo, boolean returnNonProxiedInstance) { - return getObjectDatabase().detach(iPojo, returnNonProxiedInstance); - } - - @Override - public boolean existsUserObjectByRID(ORID iRID) { - return getObjectDatabase().existsUserObjectByRID(iRID); - } - - @Override - public ODocument getRecordById(ORID iRecordId) { - return getObjectDatabase().getRecordById(iRecordId); - } - - @Override - public RET detachAll(Object iPojo, boolean returnNonProxiedInstance) { - return getObjectDatabase().detachAll(iPojo, returnNonProxiedInstance); - } - - @Override - public boolean isManaged(Object iEntity) { - return getObjectDatabase().isManaged(iEntity); - } - - @Override - public Object getUserObjectByRecord(OIdentifiable iRecord, String iFetchPlan) { - return dbf.db().getUserObjectByRecord(iRecord, iFetchPlan); - } - - @Override - public long countClass(String className) { - return getObjectDatabase().countClass(className); - } - - @Override - public long countClass(Class clazz) { - return getObjectDatabase().countClass(clazz); - } - - @Override - public OEntityManager getEntityManager() { - return getObjectDatabase().getEntityManager(); - } - - @Override - public ODatabaseDocument getUnderlying() { - return getObjectDatabase().getUnderlying(); - } - - @Override - public ORecordVersion getVersion(Object iPojo) { - return getObjectDatabase().getVersion(iPojo); - } - - @Override - public ORID getIdentity(Object iPojo) { - return getObjectDatabase().getIdentity(iPojo); - } - - @Override - public boolean isSaveOnlyDirty() { - return getObjectDatabase().isSaveOnlyDirty(); - } - - @Override - public void setSaveOnlyDirty(boolean saveOnlyDirty) { - getObjectDatabase().setSaveOnlyDirty(saveOnlyDirty); - } - - @Override - public boolean isAutomaticSchemaGeneration() { - return getObjectDatabase().isAutomaticSchemaGeneration(); - } - - @Override - public void setAutomaticSchemaGeneration(boolean automaticSchemaGeneration) { - getObjectDatabase().setAutomaticSchemaGeneration(automaticSchemaGeneration); - } - - @Override - public ODocument pojo2Stream(Object iPojo, ODocument iRecord) { - return getObjectDatabase().pojo2Stream(iPojo, iRecord); - } - - @Override - public Object stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan) { - return getObjectDatabase().stream2pojo(iRecord, iPojo, iFetchPlan); + return (RET) getObjectDatabase().detachAll(entity, true); } - @Override - public Object stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan, boolean iReload) { - return getObjectDatabase().stream2pojo(iRecord, iPojo, iFetchPlan, iReload); - } - @Override - public boolean isLazyLoading() { - return getObjectDatabase().isLazyLoading(); - } - - @Override - public void setLazyLoading(boolean lazyLoading) { - getObjectDatabase().setLazyLoading(lazyLoading); - } - - @Override - public void unregisterPojo(Object iObject, ODocument iRecord) { - getObjectDatabase().unregisterPojo(iObject, iRecord); - } - - @Override - public void registerClassMethodFilter(Class iClass, OObjectMethodFilter iMethodFilter) { - getObjectDatabase().registerClassMethodFilter(iClass, iMethodFilter); - } - - @Override - public void deregisterClassMethodFilter(Class iClass) { - getObjectDatabase().deregisterClassMethodFilter(iClass); - } - - @Override - public RET queryForObject(OSQLQuery query, Object... args) { - List list = query(query, args); - - return list.isEmpty() ? null : list.get(0); - } - - @Override - public RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args) { - RET result = queryForObject(query, args); - - switch (detachMode) { - case ENTITY: - return getObjectDatabase().detach(result, true); - case ALL: - return getObjectDatabase().detachAll(result, true); - case NONE: - } - - return result; - } - - @Override - public void registerEntityClass(Class domainClass) { - try (OObjectDatabaseTx db = getObjectDatabase()) { - db.getEntityManager().registerEntityClass(domainClass); - } - } - */ } diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/OrientObjectRepository.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/OrientObjectRepository.java index 011731a..2570cf7 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/OrientObjectRepository.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/OrientObjectRepository.java @@ -6,11 +6,11 @@ /** * The specific extension for {@link com.orientechnologies.orient.object.db.OObjectDatabaseTx} database. * - * @author Dzmitry_Naskou * @param the generic type to handle + * @author Dzmitry_Naskou */ @NoRepositoryBean public interface OrientObjectRepository extends OrientRepository { - - T detachAll(T entity); + + } diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java index d409427..00f21d1 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactory.java @@ -18,7 +18,7 @@ import java.io.Serializable; -// TODO: find out why inheriting from OrientRepositoryFactory does not work; would save some code; but this here works +//TODO: find out why inheriting from OrientRepositoryFactory does not work; would save some code; but this here works public class OrientObjectRepositoryFactory extends RepositoryFactorySupport { private final OrientObjectOperations operations; diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java index 32e53af..9a1c875 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java @@ -1,7 +1,6 @@ package org.springframework.data.orient.object.repository.support; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.orient.commons.core.OrientOperations; import org.springframework.data.orient.object.OrientObjectOperations; import org.springframework.data.repository.Repository; import org.springframework.data.repository.core.support.RepositoryFactorySupport; @@ -13,15 +12,16 @@ * Special adapter for Springs {@link org.springframework.beans.factory.FactoryBean} interface to allow easy setup of * repository factories via Spring configuration. * - * @author Dzmitry_Naskou - * - * @param the type of the repository - * @param the type of the entity to handle + * @param the type of the repository + * @param the type of the entity to handle * @param the type of the entity identifier to handle + * @author Dzmitry_Naskou */ public class OrientObjectRepositoryFactoryBean, S, ID extends Serializable> extends TransactionalRepositoryFactoryBeanSupport { - /** The orient operations. */ + /** + * The orient operations. + */ @Autowired private OrientObjectOperations operations; diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/SimpleOrientObjectRepository.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/SimpleOrientObjectRepository.java index 1141dea..9df173f 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/SimpleOrientObjectRepository.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/SimpleOrientObjectRepository.java @@ -31,9 +31,9 @@ public SimpleOrientObjectRepository(OrientObjectOperations operations, Class super(operations, domainClass, cluster, repositoryInterface); } - public T detachAll(T entity) { - // TODO: solve this issue - //return ((OrientObjectOperations) super.operations).detachAll(entity, true); - return entity; - } +// public T detachAll(T entity) { +// // TODO: solve this issue +// //return ((OrientObjectOperations) super.operations).detachAll(entity, true); +// return entity; +// } } diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java index 36a152d..2866bad 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java @@ -12,7 +12,7 @@ public interface PersonRepository extends OrientObjectRepository { - @Query("select from person where firstName = ?") +// @Query("select from person where firstName = ?") List findByFirstName(String firstName); Page findByFirstName(String firstName, Pageable pageable); @@ -36,21 +36,17 @@ public interface PersonRepository extends OrientObjectRepository { @Query(value = "select count(*) from person where firstName = ? and active = ?", count = true) Long countByFirstNameAndActive(String firstName, Boolean active); - @Detach(DetachMode.ENTITY) + @Detach(DetachMode.ALL) List findByAddress_City(String city); @FetchPlan("*:-1") - List findByAddress_Country(String city); + List findByAddress_Country(String country); List findByActiveIsTrue(); List findByActiveIsFalse(); - Long deleteByActiveIsTrue(); - - Long deleteByActiveIsFalse(); - Long deleteByActive(Boolean active); - } +} diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java index e7c58d2..e528aa7 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.orient.object.OrientDbObjectTestConfiguration; import org.springframework.data.orient.object.OrientObjectDatabaseFactory; @@ -17,7 +18,8 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {OrientDbObjectTestConfiguration.class}) @@ -35,6 +37,7 @@ public class PersonRepositoryTest { @Before public void setUp() { + //cleanup operations.command("delete from Address"); operations.command("delete from Person"); @@ -69,21 +72,42 @@ public void savePerson() { @Test public void findAllPersons() { - assertFalse(repository.findAll().isEmpty()); + assertThat(repository.findAll()) + .isNotEmpty() + .hasSize(5); + } @Test public void countPerson() { - assertEquals(repository.count(), 5L); + assertThat(repository.count()).isEqualTo(5L); } @Test public void findByFirstNamePage() { - for (Person person : repository.findByFirstName("Dzmitry", new PageRequest(1, 5)).getContent()) { + + assertThat(repository.findByFirstName("Jameson")).hasSize(1); + Page page = repository.findByFirstName("Jameson", new PageRequest(0, 5)); + + System.out.println(page.getNumberOfElements()); +// assertThat(page.getContent()) +// .hasSize(1) +// .first().extracting("firstName").isEqualTo("Dzmitry") + ; + + for (Person person : repository.findByFirstName("Dzmitry", new PageRequest(0, 5)).getContent()) { + System.out.println(person); assertEquals(person.getFirstName(), "Dzmitry"); } } + + @Test + public void findAllPaged() throws Exception { + + assertThat(repository.findAll(new PageRequest(0, 5)).getContent()).hasSize(5); + } + @Test public void countByFirstName() { assertEquals(repository.countByFirstName("Dzmitry"), Long.valueOf(1)); @@ -107,35 +131,31 @@ public void findByFirstName() { @Test public void findByFirstNameLike() { - for (Person person : repository.findByFirstNameLike("Dzm%")) { - assertTrue(person.getFirstName().startsWith("Dzm")); - } + + assertThat(repository.findByFirstNameLike("Dzm%")) + .hasSize(1) + .first() + .hasFieldOrPropertyWithValue("firstName", "Dzmitry"); } @Test public void findByLastName() { - assertFalse(repository.findByLastName("Naskou").isEmpty()); + assertThat(repository.findByLastName("Naskou")).hasSize(1); } @Test public void findByLastNameLike() { - for (Person person : repository.findByLastNameLike("Na%")) { - assertTrue(person.getLastName().startsWith("Na")); - } + assertThat(repository.findByLastNameLike("Na%")).hasSize(1); } @Test public void findByFirstNameAndLastName() { - for (Person person : repository.findByFirstNameOrLastName("Dzmitry", "Naskou")) { - assertTrue(person.getFirstName().equals("Dzmitry") && person.getLastName().equals("Naskou")); - } + assertThat(repository.findByFirstNameAndLastName("Dzmitry", "Naskou")).hasSize(1); } @Test public void findByFirstNameOrLastName() { - for (Person person : repository.findByFirstNameOrLastName("Dzmitry", "Eliot")) { - assertTrue(person.getFirstName().equals("Dzmitry") || person.getLastName().equals("Eliot")); - } + assertThat(repository.findByFirstNameOrLastName("Dzmitry", "Eliot")).hasSize(2); } @Test @@ -150,13 +170,28 @@ public void findByActiveIsFalse() { @Test public void findByCityTest() { - List persons = repository.findByAddress_City("Minsk"); - assertFalse(persons.isEmpty()); + assertThat(repository.findByAddress_City("Minsk")) + .isNotEmpty() + .hasSize(1) + .first() + .extracting("address") + .extracting("city") + .hasSize(1) + .contains("Minsk"); + } - for (Person person : persons) { - assertEquals(person.getAddress().getCity(), "Minsk"); - } + @Test + public void findByCountryTest() { + + assertThat(repository.findByAddress_Country("Belarus")) + .isNotEmpty() + .hasSize(1) + .first() + .extracting("address") + .extracting("country") + .hasSize(1) + .contains("Belarus"); } @@ -164,6 +199,7 @@ public void findByCityTest() { public void deleteByActive() { assertThat(repository.deleteByActive(false)).isEqualTo(1); assertThat(repository.deleteByActive(true)).isEqualTo(4); + assertThat(repository.count()).isEqualTo(0); } @Test diff --git a/spring-data-orientdb-object/src/test/resources/logback.xml b/spring-data-orientdb-object/src/test/resources/logback.xml index 2485041..503153d 100644 --- a/spring-data-orientdb-object/src/test/resources/logback.xml +++ b/spring-data-orientdb-object/src/test/resources/logback.xml @@ -2,7 +2,7 @@ true - %green(%d{HH:mm:ss.SSS}) [%thread] %highlight(%-5level) %cyan(%logger{36}) - %msg%n + %green(%d{HH:mm:ss.SSS}) [%thread] %highlight(%-5level) %cyan(%logger{36})[%line] - %msg%n @@ -16,12 +16,12 @@ - --> diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java index 9c3f845..612f8fa 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java @@ -20,8 +20,8 @@ public class Person { * Added to avoid a runtime error whereby the detachAll property is checked * for existence but not actually used. */ - private String detachAll; - +// private String detachAll; +// private String firstName; private String lastName; diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java index f8aa2ac..16803d2 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java @@ -1,6 +1,8 @@ package org.springframework.boot.orientdb.hello.repository; import org.springframework.boot.orientdb.hello.data.Person; +import org.springframework.data.orient.commons.repository.DetachMode; +import org.springframework.data.orient.commons.repository.annotation.Detach; import org.springframework.data.orient.commons.repository.annotation.Query; import org.springframework.data.orient.object.repository.OrientObjectRepository; @@ -8,6 +10,10 @@ public interface PersonRepository extends OrientObjectRepository { + @Override + @Detach(DetachMode.ALL) + List findAll(); + List findByFirstName(String firstName); @Query("select from person where lastName = ?") @@ -15,6 +21,5 @@ public interface PersonRepository extends OrientObjectRepository { List findByAge(Integer age); - // @Query("delete from person where age= ?") Long deleteByAge(Integer age); } From 44d44b5b44dcddb8e69f641314e209a2265d834c Mon Sep 17 00:00:00 2001 From: robfrank Date: Fri, 16 Sep 2016 17:18:41 +0200 Subject: [PATCH 19/41] [maven-release-plugin] prepare release spring-data-orientdb-parent-0.13 --- pom.xml | 43 ++++++++----------- spring-boot-orientdb-autoconfigure/pom.xml | 6 +-- spring-data-orientdb-benchmarks/pom.xml | 6 +-- spring-data-orientdb-commons/pom.xml | 6 +-- spring-data-orientdb-document/pom.xml | 6 +-- spring-data-orientdb-graph/pom.xml | 6 +-- spring-data-orientdb-object/pom.xml | 6 +-- .../spring-boot-orientdb-hello/pom.xml | 6 +-- .../spring-boot-orientdb-shiro/pom.xml | 6 +-- 9 files changed, 34 insertions(+), 57 deletions(-) diff --git a/pom.xml b/pom.xml index 8055fa9..3527827 100644 --- a/pom.xml +++ b/pom.xml @@ -14,13 +14,12 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 pom Spring Data OrientDB @@ -60,7 +59,8 @@ scm:git:git@github.com:orientechnologies/spring-data-orientdb.git scm:git:git@github.com:orientechnologies/spring-data-orientdb.git scm:git:git@github.com:orientechnologies/spring-data-orientdb.git - + spring-data-orientdb-parent-0.13 + GitHub Issues https://github.com/orientechnologies/spring-data-orientdb/issues @@ -107,11 +107,11 @@ 1.7 yyyy-MM-dd HH:mm:ssZ - + ${project.groupId}.orientdb*;version=${project.version};-noimport:=true * - - + + https://oss.sonatype.org/content/repositories/snapshots/ @@ -156,7 +156,7 @@ trainings Dzmitry Naskou - + Developer @@ -174,7 +174,7 @@ sleroy Sylvain Leroy - + Developer @@ -183,7 +183,7 @@ vidakovic Aleksandar Vidakovic - + Developer @@ -576,7 +576,7 @@ - + @@ -597,30 +597,23 @@ ${shaded.name} false - - + + META-INF/spring.handlers - + META-INF/spring.schemas - + META-INF/spring.factories - + META-INF/cxf/org.apache.cxf.bus.factory - + META-INF/cxf/bus-extensions.txt - + ${shaded.main} ${maven.compiler.source} diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index c277439..0a9b1bc 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 3964763..5da808e 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 15072c7..74c42bc 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 596085c..144aa00 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index 147453c..e7e183c 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index 74acaf7..585b1cf 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 8c3660a..c49e2e0 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index 4d30f2e..af2712c 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 com.orientechnologies spring-data-orientdb-parent - 0.13-SNAPSHOT + 0.13 ../../pom.xml From 8c6d642e06f9412712f58a3fa5c26f369894e8bb Mon Sep 17 00:00:00 2001 From: robfrank Date: Fri, 16 Sep 2016 17:18:41 +0200 Subject: [PATCH 20/41] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- .../spring-boot-orientdb-hello/pom.xml | 2 +- .../spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 3527827..10f86d1 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT pom Spring Data OrientDB @@ -59,7 +59,7 @@ scm:git:git@github.com:orientechnologies/spring-data-orientdb.git scm:git:git@github.com:orientechnologies/spring-data-orientdb.git scm:git:git@github.com:orientechnologies/spring-data-orientdb.git - spring-data-orientdb-parent-0.13 + HEAD GitHub Issues diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 0a9b1bc..e419bd6 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 5da808e..203479c 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 74c42bc..416ad2c 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 144aa00..02ba3e2 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index e7e183c..04af442 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index 585b1cf..d915f89 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index c49e2e0..392a8aa 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index af2712c..a4d8e3a 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../../pom.xml From 9ed0e61a4a43daf63eb18d619ed0605cf4649ece Mon Sep 17 00:00:00 2001 From: robfrank Date: Fri, 16 Sep 2016 18:05:22 +0200 Subject: [PATCH 21/41] releasing Spring Data OrientDB 0.13 --- pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 10f86d1..00f036f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index e419bd6..0a9b1bc 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 203479c..5da808e 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 416ad2c..74c42bc 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 02ba3e2..144aa00 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index 04af442..e7e183c 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index d915f89..585b1cf 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 392a8aa..c49e2e0 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index a4d8e3a..af2712c 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.13 ../../pom.xml From 42c4afe300b958aef48fefa3e7e490c9ed903a84 Mon Sep 17 00:00:00 2001 From: robfrank Date: Fri, 16 Sep 2016 18:16:05 +0200 Subject: [PATCH 22/41] version bumped to 0.14-SNAPSHOT --- pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 00f036f..10f86d1 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 0a9b1bc..e419bd6 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 5da808e..203479c 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 74c42bc..416ad2c 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 144aa00..02ba3e2 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index e7e183c..04af442 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index 585b1cf..d915f89 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index c49e2e0..392a8aa 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index af2712c..a4d8e3a 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.13 + 0.14-SNAPSHOT ../../pom.xml From c7641e407bd151883dbaaca769e19b09c2103248 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Wed, 12 Oct 2016 09:57:33 +0200 Subject: [PATCH 23/41] - orientDB version to 2.2.11 - fixes use of maxPoolSize :: https://github.com/orientechnologies/spring-data-orientdb/issues/61 - adds test of factory --- pom.xml | 2 +- .../core/AbstractOrientDatabaseFactory.java | 17 +---- .../commons/core/OrientDatabaseFactory.java | 10 +-- .../object/OrientObjectDatabaseFactory.java | 11 ++- .../OrientObjectDatabaseFactoryTest.java | 76 +++++++++++++++++++ .../src/test/resources/logback.xml | 10 +-- 6 files changed, 98 insertions(+), 28 deletions(-) create mode 100644 spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectDatabaseFactoryTest.java diff --git a/pom.xml b/pom.xml index 10f86d1..eb307a4 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 1.7.13 1.1.3 - 2.2.10 + 2.2.11 1.8.7 4.2.4.RELEASE 1.11.2.RELEASE diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java index 35f7c2c..eb6738a 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java @@ -70,21 +70,8 @@ public void init() { protected abstract ODatabaseInternal newDatabase(); public ODatabase db() { - ODatabase db; - if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { - db = openDatabase(); - log.debug("acquire db from pool {}", db.hashCode()); - } else { - db = (ODatabase) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); - - if (db.isClosed()) { - db = openDatabase(); - log.debug("re-opened db {}", db.hashCode()); - } else { - log.debug("use existing db {}", db.hashCode()); - } - } - + ODatabase db = openDatabase(); + log.debug("use existing db {}", db.hashCode()); return db; } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java index 4363c9c..65c63c1 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientDatabaseFactory.java @@ -6,20 +6,20 @@ public interface OrientDatabaseFactory { /** * Default database username. */ - public static final String DEFAULT_USERNAME = "admin"; + String DEFAULT_USERNAME = "admin"; /** * Default database password. */ - public static final String DEFAULT_PASSWORD = "admin"; + String DEFAULT_PASSWORD = "admin"; /** * Default maximum pool size. */ - public static final int DEFAULT_MAX_POOL_SIZE = 20; + int DEFAULT_MAX_POOL_SIZE = 20; - public ODatabase db(); + ODatabase db(); ODatabase openDatabase(); @@ -36,7 +36,7 @@ public interface OrientDatabaseFactory { void setPassword(String password); int getMaxPoolSize(); - + void setMaxPoolSize(int maxPoolSize); void dropDatabase(); diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java index f2ec0c7..2e3b079 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java @@ -1,6 +1,7 @@ package org.springframework.data.orient.object; import com.orientechnologies.orient.core.db.OPartitionedDatabasePool; +import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; import org.springframework.data.orient.commons.core.AbstractOrientDatabaseFactory; @@ -12,6 +13,7 @@ */ public class OrientObjectDatabaseFactory extends AbstractOrientDatabaseFactory { + private OPartitionedDatabasePool pool; /** @@ -21,12 +23,17 @@ public class OrientObjectDatabaseFactory extends AbstractOrientDatabaseFactory res = db.query(new OSQLSynchQuery("SELECT * FROM OUser")); + + assertThat(res).hasSize(3); + + } finally { + + db.close(); + } + } + } + + }; + + ExecutorService ex = Executors.newCachedThreadPool(); + + //spawn 20 threads + for (int i = 0; i < 20; i++) { + + ex.submit(acquirer); + } + + ex.awaitTermination(2, TimeUnit.SECONDS); + + + } +} \ No newline at end of file diff --git a/spring-data-orientdb-object/src/test/resources/logback.xml b/spring-data-orientdb-object/src/test/resources/logback.xml index 503153d..c05b273 100644 --- a/spring-data-orientdb-object/src/test/resources/logback.xml +++ b/spring-data-orientdb-object/src/test/resources/logback.xml @@ -17,11 +17,11 @@ - - - - - + + + + + From 49221a78eb07a663d9531854a8ff0fcf4b9327fc Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 13 Oct 2016 09:28:42 +0200 Subject: [PATCH 24/41] updates dependency verion to 0.13 refs https://github.com/orientechnologies/spring-data-orientdb/issues/60 --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7f94e44..9125c91 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,13 @@ Maven com.orientechnologies spring-data-orientdb-object - 0.12 + 0.13 ``` Gradle: ```groovy - group: 'com.orientechnologies', name: 'spring-data-orientdb-object', version: '0.12' + group: 'com.orientechnologies', name: 'spring-data-orientdb-object', version: '0.13' ``` ### Example @@ -40,13 +40,13 @@ Maven: com.orientechnologies spring-data-orientdb-graph - 0.12 + 0.13 ``` Gradle: ```groovy - group: 'com.orientechnologies', name: 'spring-data-orientdb-graph', version: '0.12' + group: 'com.orientechnologies', name: 'spring-data-orientdb-graph', version: '0.13' ``` @@ -55,12 +55,12 @@ Gradle: com.orientechnologies spring-data-orientdb-document - 0.12 + 0.13 ``` Gradle: ```groovy - group: 'com.orientechnologies', name: 'spring-data-orientdb-document', version: '0.12' + group: 'com.orientechnologies', name: 'spring-data-orientdb-document', version: '0.13' ``` From dea1ee815a9bb65651c81a9111889ac957a61ceb Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 13 Oct 2016 15:48:31 +0200 Subject: [PATCH 25/41] adds some tests and javadoc --- .../core/AbstractOrientDatabaseFactory.java | 17 +- .../core/AbstractOrientOperations.java | 2 +- .../orient/commons/core/OrientOperations.java | 253 ++++++++++-------- .../object/OrientObjectDatabaseFactory.java | 3 + .../OrientDbObjectTestConfiguration.java | 4 +- .../OrientObjectDatabaseFactoryTest.java | 66 ++--- .../object/OrientObjectTemplateTest.java | 67 +++++ .../object/repository/PersonRepository.java | 3 +- .../repository/PersonRepositoryTest.java | 10 +- .../src/test/resources/logback.xml | 4 +- .../orientdb/hello/HelloConfiguration.java | 13 +- 11 files changed, 259 insertions(+), 183 deletions(-) create mode 100644 spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectTemplateTest.java diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java index eb6738a..35f7c2c 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java @@ -70,8 +70,21 @@ public void init() { protected abstract ODatabaseInternal newDatabase(); public ODatabase db() { - ODatabase db = openDatabase(); - log.debug("use existing db {}", db.hashCode()); + ODatabase db; + if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { + db = openDatabase(); + log.debug("acquire db from pool {}", db.hashCode()); + } else { + db = (ODatabase) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); + + if (db.isClosed()) { + db = openDatabase(); + log.debug("re-opened db {}", db.hashCode()); + } else { + log.debug("use existing db {}", db.hashCode()); + } + } + return db; } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java index d4744f7..2fabce7 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientOperations.java @@ -542,10 +542,10 @@ public > RET query(OQuery query, DetachMode detachMode, O return detachAll(result); case NONE: } - return result; } + @Override @SuppressWarnings("unchecked") public RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args) { diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java index 0722ec0..bc55c2e 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/OrientOperations.java @@ -5,7 +5,6 @@ import com.orientechnologies.orient.core.command.OCommandRequest; import com.orientechnologies.orient.core.db.ODatabase; import com.orientechnologies.orient.core.db.ODatabaseListener; -import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.dictionary.ODictionary; import com.orientechnologies.orient.core.exception.OTransactionException; import com.orientechnologies.orient.core.hook.ORecordHook; @@ -33,43 +32,43 @@ public interface OrientOperations { - String getName(); + String getName(); - String getURL(); + String getURL(); - ODatabase database(); + ODatabase database(); - Object setProperty(String name, Object value); + Object setProperty(String name, Object value); - Object getProperty(String name); + Object getProperty(String name); - Iterator> getProperties(); + Iterator> getProperties(); - Object get(ODatabase.ATTRIBUTES attribute); + Object get(ODatabase.ATTRIBUTES attribute); - > DB set(ODatabase.ATTRIBUTES attribute, Object value); + > DB set(ODatabase.ATTRIBUTES attribute, Object value); - public void registerListener(ODatabaseListener listener); + void registerListener(ODatabaseListener listener); - public void unregisterListener(ODatabaseListener listener); + void unregisterListener(ODatabaseListener listener); - Map getHooks(); + Map getHooks(); - > DB registerHook(ORecordHook hook); + > DB registerHook(ORecordHook hook); - > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position); + > DB registerHook(ORecordHook hook, ORecordHook.HOOK_POSITION position); - > DB unregisterHook(ORecordHook hook); + > DB unregisterHook(ORecordHook hook); - void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, - int compressionLevel, int bufferSize) throws IOException; + void backup(OutputStream out, Map options, Callable callable, OCommandOutputListener listener, + int compressionLevel, int bufferSize) throws IOException; - void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) - throws IOException; + void restore(InputStream in, Map options, Callable callable, OCommandOutputListener listener) + throws IOException; - String getType(); + String getType(); - long getSize(); + long getSize(); void freeze(boolean throwException); @@ -79,175 +78,193 @@ void restore(InputStream in, Map options, Callable calla OMetadata getMetadata(); - ORecordMetadata getRecordMetadata(ORID rid); + ORecordMetadata getRecordMetadata(ORID rid); - ODictionary getDictionary(); + ODictionary getDictionary(); - boolean declareIntent(OIntent intent); + boolean declareIntent(OIntent intent); - public boolean isMVCC(); + boolean isMVCC(); - public > DB setMVCC(boolean mvcc); + > DB setMVCC(boolean mvcc); - boolean isClosed(); + boolean isClosed(); - void reload(); + void reload(); - T reload(T entity, String fetchPlan, boolean ignoreCache); + T reload(T entity, String fetchPlan, boolean ignoreCache); - ODatabase.STATUS getStatus(); + ODatabase.STATUS getStatus(); - > DB setStatus(ODatabase.STATUS status); + > DB setStatus(ODatabase.STATUS status); - OTransaction getTransaction(); + OTransaction getTransaction(); - ODatabase begin(); + ODatabase begin(); - ODatabase begin(OTransaction.TXTYPE type); + ODatabase begin(OTransaction.TXTYPE type); - ODatabase begin(OTransaction tx); + ODatabase begin(OTransaction tx); - ODatabase commit(); + ODatabase commit(); - ODatabase commit(boolean force) throws OTransactionException; + ODatabase commit(boolean force) throws OTransactionException; - ODatabase rollback(); + ODatabase rollback(); - ODatabase rollback(boolean force) throws OTransactionException; + ODatabase rollback(boolean force) throws OTransactionException; - OLocalRecordCache getLevel2Cache(); + OLocalRecordCache getLevel2Cache(); - T newInstance(); + T newInstance(); - T load(ORID recordId); + T load(ORID recordId); - T load(String recordId); + T load(String recordId); - T load(T entity); + T load(T entity); - T load(T entity, String fetchPlan); + T load(T entity, String fetchPlan); - T load(T entity, String fetchPlan, boolean ignoreCache); + T load(T entity, String fetchPlan, boolean ignoreCache); - T load(ORID recordId, String fetchPlan); + T load(ORID recordId, String fetchPlan); - T load(ORID recordId, String fetchPlan, boolean ignoreCache); + T load(ORID recordId, String fetchPlan, boolean ignoreCache); - T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); + T load(T entity, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); - T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); + T load(ORID recordId, String fetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY lockingStrategy); - S save(S entity); + S save(S entity); - S save(S entity, String cluster); + S save(S entity, String cluster); - S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, - ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback); + S save(S entity, ODatabase.OPERATION_MODE mode, boolean forceCreate, + ORecordCallback recordCallback, ORecordCallback recordUpdatedCallback); - long countClass(String className); + /** + * Counts the elements of a class + * + * @param className + * @return the count value + */ + long countClass(String className); - long countClass(Class clazz); + /** + * Counts the elements of a class + * + * @param clazz + * @return the count value + */ + long countClass(Class clazz); - long count(OSQLQuery query, Object... args); + /** + * Returns the count value for the {@link OSQLQuery} passed as parameter. + * Useful to count results of a query with conditions, e.g.: + * SELECT count(*) FROM Person WHERE age > 18 + * + * @param query that contains a count() + * @param args optional args for the query if it is parametrized + * @return the count value of the query + */ + long count(OSQLQuery query, Object... args); - long countClusterElements(String clusterName); + long countClusterElements(String clusterName); - long countClusterElements(int clusterId); + long countClusterElements(int clusterId); - long countClusterElements(int[] clusterIds); + long countClusterElements(int[] clusterIds); - long countClusterElements(int iClusterId, boolean countTombstones); + long countClusterElements(int iClusterId, boolean countTombstones); - long countClusterElements(int[] iClusterIds, boolean countTombstones); + long countClusterElements(int[] iClusterIds, boolean countTombstones); - int getClusters(); + int getClusters(); - boolean existsCluster(String iClusterName); + boolean existsCluster(String iClusterName); - Collection getClusterNames(); + Collection getClusterNames(); - ODatabase delete(ORID recordId); + ODatabase delete(ORID recordId); - ODatabase delete(T entity); + ODatabase delete(T entity); - ODatabase delete(ORID rid, int version); + ODatabase delete(ORID rid, int version); - int getDefaultClusterId(); + int getDefaultClusterId(); - int getDefaultClusterId(Class domainClass); + int getDefaultClusterId(Class domainClass); - String getClusterNameById(int clusterId); + String getClusterNameById(int clusterId); - int getClusterIdByName(String clusterName); + int getClusterIdByName(String clusterName); - int getClusterIdByName(String clusterName, Class clazz); + int getClusterIdByName(String clusterName, Class clazz); - String getClusterNameByRid(String rid); + String getClusterNameByRid(String rid); - List getClusterNamesByClass(Class clazz, boolean includeDefault); + List getClusterNamesByClass(Class clazz, boolean includeDefault); - long getClusterRecordSizeById(int clusterId); + long getClusterRecordSizeById(int clusterId); - long getClusterRecordSizeByName(String clusterName); + long getClusterRecordSizeByName(String clusterName); - int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params); + int addCluster(String type, String clusterName, String location, String dataSegmentName, Object... params); - int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, Object... params); + int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, Object... params); - int addCluster(String clusterName, Object... params); + int addCluster(String clusterName, Object... params); - int addCluster(String clusterName); + int addCluster(String clusterName); - boolean isDefault(String clusterName); + boolean isDefault(String clusterName); - /** - * Is Class registered in OrientDb - * - * @param clazz - * class to check - * @return Is Class registered in OrientDb - */ - boolean existsClass(Class clazz); + /** + * Is Class registered in OrientDb + * + * @param clazz class to check + * @return Is Class registered in OrientDb + */ + boolean existsClass(Class clazz); - /** - * Is Class registered in OrientDb - * - * @param className - * simple class name (clazz.getSimpleName()) - * @return Is Class registered in OrientDb - */ - boolean existsClass(String className); + /** + * Is Class registered in OrientDb + * + * @param className simple class name (clazz.getSimpleName()) + * @return Is Class registered in OrientDb + */ + boolean existsClass(String className); - /** - * Find field annotated with {@link com.orientechnologies.orient.core.annotation.OId} in entity and return it's value. - * - * @param entity - * Orient Entity - * @return orient row ID or null if it is to found - */ - String getRid(T entity); + /** + * Find field annotated with {@link com.orientechnologies.orient.core.annotation.OId} in entity and return it's value. + * + * @param entity Orient Entity + * @return orient row ID or null if it is to found + */ + String getRid(T entity); - OSecurityUser getUser(); + OSecurityUser getUser(); - > RET detach(RET entities); + > RET detach(RET entities); - > RET detachAll(RET list); + > RET detachAll(RET list); - RET detach(RET entity); + RET detach(RET entity); - RET detachAll(RET entity); + RET detachAll(RET entity); - > RET query(OQuery query, Object... args); + > RET query(OQuery query, Object... args); - > RET query(OQuery query, DetachMode detachMode, Object... args); + > RET query(OQuery query, DetachMode detachMode, Object... args); - RET queryForObject(OSQLQuery query, Object... args); + RET queryForObject(OSQLQuery query, Object... args); - RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args); + RET queryForObject(OSQLQuery query, DetachMode detachMode, Object... args); - RET command(OCommandRequest command); + RET command(OCommandRequest command); - RET command(OCommandSQL command, Object... args); + RET command(OCommandSQL command, Object... args); - RET command(String sql, Object... args); + RET command(String sql, Object... args); } diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java index 2e3b079..cf7661b 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/OrientObjectDatabaseFactory.java @@ -3,6 +3,8 @@ import com.orientechnologies.orient.core.db.OPartitionedDatabasePool; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.data.orient.commons.core.AbstractOrientDatabaseFactory; /** @@ -13,6 +15,7 @@ */ public class OrientObjectDatabaseFactory extends AbstractOrientDatabaseFactory { + private static Logger log = LoggerFactory.getLogger(AbstractOrientDatabaseFactory.class); private OPartitionedDatabasePool pool; diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java index 238426c..ef03bfa 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientDbObjectTestConfiguration.java @@ -36,10 +36,10 @@ public class OrientDbObjectTestConfiguration { public OrientObjectDatabaseFactory factory() { OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); - //factory.setUrl("plocal:target/spring-data-orientdb-db"); factory.setUrl("memory:spring-data-orientdb-db"); factory.setUsername("admin"); factory.setPassword("admin"); + factory.setMaxPoolSize(2); return factory; } @@ -73,5 +73,7 @@ public void registerEntities() { db.getMetadata().getSchema().getClass(Employee.class).addClusterId(id); } + db.close(); + } } diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectDatabaseFactoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectDatabaseFactoryTest.java index 0a68628..48dd2c6 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectDatabaseFactoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectDatabaseFactoryTest.java @@ -6,6 +6,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.concurrent.ExecutorService; @@ -14,63 +19,32 @@ import static org.assertj.core.api.Assertions.assertThat; -/** - * Created by frank on 11/10/2016. - */ +@Transactional +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {OrientDbObjectTestConfiguration.class}) public class OrientObjectDatabaseFactoryTest { + @Autowired + OrientObjectDatabaseFactory factory; + @Rule public TestName name = new TestName(); - @Test - public void shouldUseMaxPoolSize() throws Exception { - - final OrientObjectDatabaseFactory fc = new OrientObjectDatabaseFactory(); - - fc.setUrl("memory:" + name.getMethodName()); - fc.setUsername("admin"); - fc.setPassword("admin"); - fc.setMaxPoolSize(10); - fc.init(); - - //do a query and assert on other thread - Runnable acquirer = new Runnable() { - @Override - public void run() { - - //call th db 10 times in the same thread - for (int i = 0; i < 10; i++) { - - OObjectDatabaseTx db = fc.db(); - -// System.out.println(Thread.currentThread().getName() + " :: " + db.getUnderlying().hashCode()); - try { - assertThat(db.isActiveOnCurrentThread()).isTrue(); - List res = db.query(new OSQLSynchQuery("SELECT * FROM OUser")); - - assertThat(res).hasSize(3); - - } finally { - - db.close(); - } - } - } - - }; - - ExecutorService ex = Executors.newCachedThreadPool(); + @Test + public void shouldCountClassElements() throws Exception { - //spawn 20 threads - for (int i = 0; i < 20; i++) { + OObjectDatabaseTx db = factory.db(); - ex.submit(acquirer); - } + assertThat(db.countClass("OUser")).isEqualTo(3); + } - ex.awaitTermination(2, TimeUnit.SECONDS); + @Test + public void shouldCountClusterElements() throws Exception { + OObjectDatabaseTx db = factory.db(); + assertThat(db.countClusterElements("OUser")).isEqualTo(3); } } \ No newline at end of file diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectTemplateTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectTemplateTest.java new file mode 100644 index 0000000..afc4b33 --- /dev/null +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/OrientObjectTemplateTest.java @@ -0,0 +1,67 @@ +package org.springframework.data.orient.object; + +import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; +import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExternalResource; +import org.junit.rules.TestName; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Created by frank on 12/10/2016. + */ +public class OrientObjectTemplateTest { + + @Rule + public TestName name = new TestName(); + + private OrientObjectTemplate template; + private OrientObjectDatabaseFactory fc; + @Rule + public ExternalResource database = new ExternalResource() { + @Override + protected void before() throws Throwable { + fc = new OrientObjectDatabaseFactory(); + fc.setUrl("memory:" + name.getMethodName()); + fc.setUsername("admin"); + fc.setPassword("admin"); + fc.setMaxPoolSize(2); + //post-construct annotated method for spring + fc.init(); + + template = new OrientObjectTemplate(fc); + + } + + @Override + protected void after() { + + new ODatabaseDocumentTx("memory:" + name.getMethodName()).open("admin", "admin").drop(); + } + }; + + @Test + public void testClassOperations() throws Exception { + + assertThat(template.countClass("OUser")).isEqualTo(3); + + assertThat(template.count(new OSQLSynchQuery<>("Select count(*) from Ouser"))).isEqualTo(3); + + assertThat(template.existsClass("OUser")).isTrue(); + + + } + + @Test + public void testClusterOperations() throws Exception { + + assertThat(template.countClusterElements("OUser")).isEqualTo(3); + + assertThat(template.existsCluster("OUser")).isTrue(); + + } + + +} \ No newline at end of file diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java index 2866bad..de4327a 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepository.java @@ -10,9 +10,10 @@ import java.util.List; + public interface PersonRepository extends OrientObjectRepository { -// @Query("select from person where firstName = ?") + // @Query("select from person where firstName = ?") List findByFirstName(String firstName); Page findByFirstName(String firstName, Pageable pageable); diff --git a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java index e528aa7..0839c2f 100644 --- a/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java +++ b/spring-data-orientdb-object/src/test/java/org/springframework/data/orient/object/repository/PersonRepositoryTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {OrientDbObjectTestConfiguration.class}) public class PersonRepositoryTest { @@ -89,11 +90,6 @@ public void findByFirstNamePage() { assertThat(repository.findByFirstName("Jameson")).hasSize(1); Page page = repository.findByFirstName("Jameson", new PageRequest(0, 5)); - System.out.println(page.getNumberOfElements()); -// assertThat(page.getContent()) -// .hasSize(1) -// .first().extracting("firstName").isEqualTo("Dzmitry") - ; for (Person person : repository.findByFirstName("Dzmitry", new PageRequest(0, 5)).getContent()) { System.out.println(person); @@ -103,7 +99,7 @@ public void findByFirstNamePage() { @Test - public void findAllPaged() throws Exception { + public void findAllPaged() { assertThat(repository.findAll(new PageRequest(0, 5)).getContent()).hasSize(5); } @@ -215,4 +211,6 @@ public void countByFirstNameAndActive() { } + } + diff --git a/spring-data-orientdb-object/src/test/resources/logback.xml b/spring-data-orientdb-object/src/test/resources/logback.xml index c05b273..089835d 100644 --- a/spring-data-orientdb-object/src/test/resources/logback.xml +++ b/spring-data-orientdb-object/src/test/resources/logback.xml @@ -16,12 +16,12 @@ - + + --> diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java index bf28d91..17a7f8c 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java @@ -1,14 +1,15 @@ package org.springframework.boot.orientdb.hello; -import javax.annotation.PostConstruct; +import org.springframework.boot.orientdb.hello.data.Person; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.data.orient.commons.core.OrientTransactionManager; import org.springframework.data.orient.commons.repository.config.EnableOrientRepositories; import org.springframework.data.orient.object.OrientObjectDatabaseFactory; -import org.springframework.data.orient.commons.core.OrientTransactionManager; import org.springframework.data.orient.object.OrientObjectTemplate; -import org.springframework.boot.orientdb.hello.data.Person; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.annotation.PostConstruct; @Configuration @EnableTransactionManagement @@ -17,12 +18,12 @@ public class HelloConfiguration { @Bean public OrientObjectDatabaseFactory factory() { - OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); + OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); -// factory.setUrl("remote:127.0.0.1/GratefulDeadConcerts"); factory.setUrl("memory:helloDb"); factory.setUsername("admin"); factory.setPassword("admin"); + factory.setMaxPoolSize(10); return factory; } From db2f9cade2307820db328a4b36d03e7e21aec8fa Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Fri, 14 Oct 2016 13:47:09 +0200 Subject: [PATCH 26/41] avoid threadlocal on AbstractOrientDatabaseFactory --- .../core/AbstractOrientDatabaseFactory.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java index 35f7c2c..d385989 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/core/AbstractOrientDatabaseFactory.java @@ -70,21 +70,8 @@ public void init() { protected abstract ODatabaseInternal newDatabase(); public ODatabase db() { - ODatabase db; - if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { - db = openDatabase(); - log.debug("acquire db from pool {}", db.hashCode()); - } else { - db = (ODatabase) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); - - if (db.isClosed()) { - db = openDatabase(); - log.debug("re-opened db {}", db.hashCode()); - } else { + ODatabase db = openDatabase(); log.debug("use existing db {}", db.hashCode()); - } - } - return db; } From 18d9422b915b30af4a35baa519701691a4c2b821 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 28 Nov 2016 09:51:34 +0100 Subject: [PATCH 27/41] adds Jenkinsfilel for build pipeline --- Jenkinsfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..c831265 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,30 @@ +#!groovy +node("master") { + def mvnHome = tool 'mvn' + def mvnJdk8Image = "orientdb/mvn-gradle-zulu-jdk-8:20161125" + + stage('Source checkout') { + + checkout scm + } + + stage('Run tests on Java8') { + docker.image("${mvnJdk8Image}").inside("${env.VOLUMES}") { + try { + + sh "${mvnHome}/bin/mvn --batch-mode -V -U clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" + } catch (e) { + currentBuild.result = 'FAILURE' + + slackSend(color: 'bad', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") + } finally { + junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml' + + } + + + } + } + +} + From f8d13a6d80671550a8b3646644bd17fffd9a185e Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 24 Apr 2017 12:17:37 +0200 Subject: [PATCH 28/41] updates srping boot and spring data versions. --- pom.xml | 8 +-- .../query/OrientQueryLookupStrategy.java | 53 +++++++++++-------- .../repository/query/OrientQueryMethod.java | 39 ++++++++------ .../support/OrientRepositoryFactoryBean.java | 9 ++++ .../OrientObjectRepositoryFactoryBean.java | 9 ++++ .../sample/shiro/rest/UserControllerTest.java | 8 ++- 6 files changed, 77 insertions(+), 49 deletions(-) diff --git a/pom.xml b/pom.xml index eb307a4..4d1ce35 100644 --- a/pom.xml +++ b/pom.xml @@ -117,11 +117,11 @@ 1.7.13 1.1.3 - 2.2.11 + 2.2.18 1.8.7 - 4.2.4.RELEASE - 1.11.2.RELEASE - 1.3.1.RELEASE + 4.3.7.RELEASE + 1.13.3.RELEASE + 1.5.2.RELEASE 3.7.2 1.4.1 4.12 diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryLookupStrategy.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryLookupStrategy.java index 3745f78..1866aff 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryLookupStrategy.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryLookupStrategy.java @@ -1,18 +1,38 @@ package org.springframework.data.orient.commons.repository.query; import org.springframework.data.orient.commons.core.OrientOperations; +import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.repository.core.NamedQueries; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.query.QueryLookupStrategy; import org.springframework.data.repository.query.QueryLookupStrategy.Key; import org.springframework.data.repository.query.RepositoryQuery; +import java.lang.reflect.Method; + public final class OrientQueryLookupStrategy { private OrientQueryLookupStrategy() { super(); } + public static QueryLookupStrategy create(OrientOperations operations, Key key) { + if (key == null) { + return new CreateIfNotFoundQueryLookupStrategy(operations); + } + + switch (key) { + case CREATE: + return new CreateQueryLookupStrategy(operations); + case USE_DECLARED_QUERY: + return new DeclaredQueryLookupStrategy(operations); + case CREATE_IF_NOT_FOUND: + return new CreateIfNotFoundQueryLookupStrategy(operations); + default: + throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key)); + } + } + private abstract static class AbstractQueryLookupStrategy implements QueryLookupStrategy { private final OrientOperations operations; @@ -23,14 +43,14 @@ public AbstractQueryLookupStrategy(OrientOperations template) { /* * (non-Javadoc) - * + * * @see org.springframework.data.repository.query.QueryLookupStrategy# * resolveQuery(java.lang.reflect.Method, * org.springframework.data.repository.core.RepositoryMetadata, * org.springframework.data.repository.core.NamedQueries) */ - public final RepositoryQuery resolveQuery(java.lang.reflect.Method method, RepositoryMetadata metadata, NamedQueries namedQueries) { - return resolveQuery(new OrientQueryMethod(method, metadata), operations, namedQueries); + public final RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory, NamedQueries namedQueries) { + return resolveQuery(new OrientQueryMethod(method, metadata,factory), operations, namedQueries); } protected abstract RepositoryQuery resolveQuery(OrientQueryMethod method, OrientOperations template, NamedQueries namedQueries); @@ -41,7 +61,7 @@ private static class CreateQueryLookupStrategy extends AbstractQueryLookupStrate /** * Instantiates a new {@link CreateQueryLookupStrategy} lookup strategy. * - * @param db the application database service + * @param template the application database service */ public CreateQueryLookupStrategy(OrientOperations template) { super(template); @@ -88,10 +108,14 @@ protected RepositoryQuery resolveQuery(OrientQueryMethod method, OrientOperation private static class CreateIfNotFoundQueryLookupStrategy extends AbstractQueryLookupStrategy { - /** The declared query strategy. */ + /** + * The declared query strategy. + */ private final DeclaredQueryLookupStrategy strategy; - /** The create query strategy. */ + /** + * The create query strategy. + */ private final CreateQueryLookupStrategy createStrategy; /** @@ -118,21 +142,4 @@ protected RepositoryQuery resolveQuery(OrientQueryMethod method, OrientOperation } } - public static QueryLookupStrategy create(OrientOperations operations, Key key) { - if (key == null) { - return new CreateIfNotFoundQueryLookupStrategy(operations); - } - - switch (key) { - case CREATE: - return new CreateQueryLookupStrategy(operations); - case USE_DECLARED_QUERY: - return new DeclaredQueryLookupStrategy(operations); - case CREATE_IF_NOT_FOUND: - return new CreateIfNotFoundQueryLookupStrategy(operations); - default: - throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key)); - } - } - } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryMethod.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryMethod.java index 22d2f1d..789b102 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryMethod.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/query/OrientQueryMethod.java @@ -1,10 +1,11 @@ package org.springframework.data.orient.commons.repository.query; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.data.orient.commons.repository.annotation.Detach; import org.springframework.data.orient.commons.repository.DetachMode; +import org.springframework.data.orient.commons.repository.annotation.Detach; import org.springframework.data.orient.commons.repository.annotation.FetchPlan; import org.springframework.data.orient.commons.repository.annotation.Query; +import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.query.QueryMethod; import org.springframework.util.StringUtils; @@ -18,24 +19,28 @@ */ public final class OrientQueryMethod extends QueryMethod { - /** The method. */ + /** + * The method. + */ private final Method method; - /** The repository interface. */ + /** + * The repository interface. + */ private final Class repositoryInterface; /** * Instantiates a new {@link OrientQueryMethod}. * - * @param method the method + * @param method the method * @param metadata the metadata */ - public OrientQueryMethod(Method method, RepositoryMetadata metadata) { - super(method, metadata); + public OrientQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) { + super(method, metadata, factory); this.method = method; this.repositoryInterface = metadata.getRepositoryInterface(); } - + /* (non-Javadoc) * @see org.springframework.data.repository.query.QueryMethod#createParameters(java.lang.reflect.Method) */ @@ -69,13 +74,13 @@ public Class getRepositoryInterface() { /** * Returns whether the method has an annotated query. - * + * * @return */ public boolean hasAnnotatedQuery() { return getAnnotatedQuery() != null; } - + /** * Returns the query string declared in a {@link Query} annotation or {@literal null} if neither the annotation found * nor the attribute was specified. @@ -86,33 +91,33 @@ String getAnnotatedQuery() { String query = (String) AnnotationUtils.getValue(getQueryAnnotation()); return StringUtils.hasText(query) ? query : null; } - + /** * Returns the {@link Query} annotation that is applied to the method or {@code null} if none available. - * + * * @return */ Query getQueryAnnotation() { return method.getAnnotation(Query.class); } - + FetchPlan getFetchPlanAnnotation() { return method.getAnnotation(FetchPlan.class); } - + String getFetchPlan() { String plan = (String) AnnotationUtils.getValue(getFetchPlanAnnotation()); - + return StringUtils.hasText(plan) ? plan : null; } - + Detach getDetachAnnotation() { return method.getAnnotation(Detach.class); } - + DetachMode getDetachMode() { DetachMode mode = (DetachMode) AnnotationUtils.getValue(getDetachAnnotation()); - + return mode == null ? DetachMode.NONE : mode; } } diff --git a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactoryBean.java b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactoryBean.java index 712aa20..423ec87 100644 --- a/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactoryBean.java +++ b/spring-data-orientdb-commons/src/main/java/org/springframework/data/orient/commons/repository/support/OrientRepositoryFactoryBean.java @@ -24,6 +24,15 @@ public class OrientRepositoryFactoryBean, S, ID exte @Autowired private OrientOperations operations; + /** + * Creates a new {@link TransactionalRepositoryFactoryBeanSupport} for the given repository interface. + * + * @param repositoryInterface must not be {@literal null}. + */ + protected OrientRepositoryFactoryBean(Class repositoryInterface) { + super(repositoryInterface); + } + /* (non-Javadoc) * @see org.springframework.data.repository.core.support.TransactionalRepositoryFactoryBeanSupport#doCreateRepositoryFactory() */ diff --git a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java index 9a1c875..aa451b4 100644 --- a/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java +++ b/spring-data-orientdb-object/src/main/java/org/springframework/data/orient/object/repository/support/OrientObjectRepositoryFactoryBean.java @@ -25,6 +25,15 @@ public class OrientObjectRepositoryFactoryBean, S, I @Autowired private OrientObjectOperations operations; + /** + * Creates a new {@link TransactionalRepositoryFactoryBeanSupport} for the given repository interface. + * + * @param repositoryInterface must not be {@literal null}. + */ + protected OrientObjectRepositoryFactoryBean(Class repositoryInterface) { + super(repositoryInterface); + } + @Override protected RepositoryFactorySupport doCreateRepositoryFactory() { return new OrientObjectRepositoryFactory(operations); diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java index 3f8a37c..f9e572e 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/src/test/java/org/springframework/boot/orient/sample/shiro/rest/UserControllerTest.java @@ -29,9 +29,8 @@ import org.springframework.boot.orient.sample.shiro.repository.PermissionRepository; import org.springframework.boot.orient.sample.shiro.repository.RoleRepository; import org.springframework.boot.orient.sample.shiro.repository.UserRepository; -import org.springframework.boot.test.IntegrationTest; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.boot.test.TestRestTemplate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.*; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -44,9 +43,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; -@SpringApplicationConfiguration(classes = {Application.class, OrientDbConfiguration.class, ShiroConfiguration.class}) +@SpringBootTest(classes = {Application.class, OrientDbConfiguration.class, ShiroConfiguration.class}) @WebAppConfiguration -@IntegrationTest @TestExecutionListeners(inheritListeners = false, listeners = {DependencyInjectionTestExecutionListener.class}) @RunWith(SpringJUnit4ClassRunner.class) public class UserControllerTest { From 1f627143edb9bcdf8052a06758cb2cdad2ad5bed Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 24 Apr 2017 12:42:18 +0200 Subject: [PATCH 29/41] updates versions of dependencies --- pom.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 4d1ce35..5811a3e 100644 --- a/pom.xml +++ b/pom.xml @@ -115,17 +115,16 @@ https://oss.sonatype.org/content/repositories/snapshots/ - 1.7.13 - 1.1.3 + 1.7.22 + 1.1.9 2.2.18 - 1.8.7 + 1.8.9 4.3.7.RELEASE 1.13.3.RELEASE 1.5.2.RELEASE - 3.7.2 + 3.9.2 1.4.1 4.12 - 6.8.21 2.4.0 https://oss.sonatype.org/content/repositories/snapshots/ From 7e6dee81733440fa998f6cf0f164d991ddbfc25c Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Tue, 2 May 2017 15:05:07 +0200 Subject: [PATCH 30/41] updates versions to 2.2.19 and reformat some code --- .gitignore | 70 ++++++++++ pom.xml | 4 +- .../boot/orientdb/hello/HelloApplication.java | 120 +++++++++--------- .../orientdb/hello/HelloConfiguration.java | 53 ++++---- .../boot/orientdb/hello/data/Person.java | 72 +++++------ .../hello/repository/PersonRepository.java | 16 +-- .../orientdb/hello/rest/PersonController.java | 54 ++++---- 7 files changed, 226 insertions(+), 163 deletions(-) diff --git a/.gitignore b/.gitignore index 700dec6..40c3cec 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,73 @@ target *.ipr *.iws atlassian-ide-plugin.xml +### Maven template +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) +!/.mvn/wrapper/maven-wrapper.jar +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Gradle template +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties diff --git a/pom.xml b/pom.xml index 5811a3e..8a075d7 100644 --- a/pom.xml +++ b/pom.xml @@ -117,11 +117,11 @@ 1.7.22 1.1.9 - 2.2.18 + 2.2.19 1.8.9 4.3.7.RELEASE 1.13.3.RELEASE - 1.5.2.RELEASE + 1.5.3.RELEASE 3.9.2 1.4.1 4.12 diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloApplication.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloApplication.java index f1c5fc5..63d59f0 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloApplication.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloApplication.java @@ -23,69 +23,69 @@ @EnableOrientRepositories("org.springframework.boot.orientdb.hello.repository") public class HelloApplication implements CommandLineRunner { - @Autowired - private PersonRepository repository; + @Autowired + private PersonRepository repository; - @Autowired - private OrientObjectDatabaseFactory factory; + @Autowired + private OrientObjectDatabaseFactory factory; - public static void main(String[] args) { - SpringApplication.run(HelloApplication.class, args); + public static void main(String[] args) { + SpringApplication.run(HelloApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + OObjectDatabaseTx db = null; + + try { + db = factory.openDatabase(); + db.getEntityManager().registerEntityClass(Person.class); + } finally { + if (db != null) { + db.close(); + } } - @Override - public void run(String... args) throws Exception { - OObjectDatabaseTx db = null; - - try { - db = factory.openDatabase(); - db.getEntityManager().registerEntityClass(Person.class); - } finally { - if (db != null) { - db.close(); - } - } - - //Create Persons if required - if (repository.count() < 1) { - List persons = new ArrayList(); - - Person graham = new Person(); - graham.setFirstName("Graham"); - graham.setLastName("Jacobson"); - graham.setAge(25); - - persons.add(graham); - - Person ebony = new Person(); - ebony.setFirstName("Ebony"); - ebony.setLastName("Irwin"); - ebony.setAge(21); - - persons.add(ebony); - - Person benedict = new Person(); - benedict.setFirstName("Benedict"); - benedict.setLastName("Preston"); - benedict.setAge(25); - - persons.add(benedict); - - Person zorita = new Person(); - zorita.setFirstName("Zorita"); - zorita.setLastName("Clements"); - zorita.setAge(23); - - persons.add(zorita); - - Person kaitlin = new Person(); - kaitlin.setFirstName("Kaitlin"); - kaitlin.setLastName("Walter"); - kaitlin.setAge(22); - - persons.add(kaitlin); - - repository.save(persons); - } + //Create Persons if required + if (repository.count() < 1) { + List persons = new ArrayList(); + + Person graham = new Person(); + graham.setFirstName("Graham"); + graham.setLastName("Jacobson"); + graham.setAge(25); + + persons.add(graham); + + Person ebony = new Person(); + ebony.setFirstName("Ebony"); + ebony.setLastName("Irwin"); + ebony.setAge(21); + + persons.add(ebony); + + Person benedict = new Person(); + benedict.setFirstName("Benedict"); + benedict.setLastName("Preston"); + benedict.setAge(25); + + persons.add(benedict); + + Person zorita = new Person(); + zorita.setFirstName("Zorita"); + zorita.setLastName("Clements"); + zorita.setAge(23); + + persons.add(zorita); + + Person kaitlin = new Person(); + kaitlin.setFirstName("Kaitlin"); + kaitlin.setLastName("Walter"); + kaitlin.setAge(22); + + persons.add(kaitlin); + + repository.save(persons); } + } } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java index 17a7f8c..b5dfef3 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/HelloConfiguration.java @@ -16,31 +16,30 @@ @EnableOrientRepositories(basePackages = "org.springframework.boot.orientdb.hello.data") public class HelloConfiguration { - @Bean - public OrientObjectDatabaseFactory factory() { - OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); - - factory.setUrl("memory:helloDb"); - factory.setUsername("admin"); - factory.setPassword("admin"); - factory.setMaxPoolSize(10); - - return factory; - } - - @Bean - public OrientTransactionManager transactionManager() { - return new OrientTransactionManager(factory()); - } - - @Bean - public OrientObjectTemplate objectTemplate() { - return new OrientObjectTemplate(factory()); - } - - - @PostConstruct - public void registerEntities() { - factory().db().getEntityManager().registerEntityClass(Person.class); - } + @Bean + public OrientObjectDatabaseFactory factory() { + OrientObjectDatabaseFactory factory = new OrientObjectDatabaseFactory(); + + factory.setUrl("memory:helloDb"); + factory.setUsername("admin"); + factory.setPassword("admin"); + factory.setMaxPoolSize(10); + + return factory; + } + + @Bean + public OrientTransactionManager transactionManager() { + return new OrientTransactionManager(factory()); + } + + @Bean + public OrientObjectTemplate objectTemplate() { + return new OrientObjectTemplate(factory()); + } + + @PostConstruct + public void registerEntities() { + factory().db().getEntityManager().registerEntityClass(Person.class); + } } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java index 612f8fa..eb2a66d 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/data/Person.java @@ -6,57 +6,51 @@ import javax.persistence.Id; import javax.persistence.Version; -@JsonIgnoreProperties(value = {"handler"}) +@JsonIgnoreProperties(value = { "handler" }) public class Person { - @Id - private String id; + @Id + private String id; - @Version - @JsonIgnore - private Long version; + @Version + @JsonIgnore + private Long version; - /** - * Added to avoid a runtime error whereby the detachAll property is checked - * for existence but not actually used. - */ -// private String detachAll; -// - private String firstName; + private String firstName; - private String lastName; + private String lastName; - private Integer age; + private Integer age; - public String getId() { - return id; - } + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public String getFirstName() { - return firstName; - } + public String getFirstName() { + return firstName; + } - public void setFirstName(String firstName) { - this.firstName = firstName; - } + public void setFirstName(String firstName) { + this.firstName = firstName; + } - public String getLastName() { - return lastName; - } + public String getLastName() { + return lastName; + } - public void setLastName(String lastName) { - this.lastName = lastName; - } + public void setLastName(String lastName) { + this.lastName = lastName; + } - public Integer getAge() { - return age; - } + public Integer getAge() { + return age; + } - public void setAge(Integer age) { - this.age = age; - } + public void setAge(Integer age) { + this.age = age; + } } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java index 16803d2..ceb95c1 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/repository/PersonRepository.java @@ -10,16 +10,16 @@ public interface PersonRepository extends OrientObjectRepository { - @Override - @Detach(DetachMode.ALL) - List findAll(); + @Override + @Detach(DetachMode.ALL) + List findAll(); - List findByFirstName(String firstName); + List findByFirstName(String firstName); - @Query("select from person where lastName = ?") - List findByLastName(String lastName); + @Query("select from person where lastName = ?") + List findByLastName(String lastName); - List findByAge(Integer age); + List findByAge(Integer age); - Long deleteByAge(Integer age); + Long deleteByAge(Integer age); } diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java index 7f5968d..299cb6c 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/src/main/java/org/springframework/boot/orientdb/hello/rest/PersonController.java @@ -14,31 +14,31 @@ @RequestMapping("/persons") public class PersonController { - @Autowired - private PersonRepository repository; - - @RequestMapping(method = RequestMethod.GET) - public List findAllPersons() { - return repository.findAll(); - } - - @RequestMapping("/findByFirstName") - public List findByFirstName(@RequestParam String firstName) { - return repository.findByFirstName(firstName); - } - - @RequestMapping("/findByLastName") - public List findByLastName(@RequestParam String lastName) { - return repository.findByLastName(lastName); - } - - @RequestMapping("/findByAge") - public List findByAge(@RequestParam Integer age) { - return repository.findByAge(age); - } - - @RequestMapping("/deleteByAge") - public Long deleteByAge(@RequestParam Integer age) { - return repository.deleteByAge(age); - } + @Autowired + private PersonRepository repository; + + @RequestMapping(method = RequestMethod.GET) + public List findAllPersons() { + return repository.findAll(); + } + + @RequestMapping("/findByFirstName") + public List findByFirstName(@RequestParam String firstName) { + return repository.findByFirstName(firstName); + } + + @RequestMapping("/findByLastName") + public List findByLastName(@RequestParam String lastName) { + return repository.findByLastName(lastName); + } + + @RequestMapping("/findByAge") + public List findByAge(@RequestParam Integer age) { + return repository.findByAge(age); + } + + @RequestMapping("/deleteByAge") + public Long deleteByAge(@RequestParam Integer age) { + return repository.deleteByAge(age); + } } From 2837775ee89256d32bff4c4ac110ebeb9dac4308 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Mon, 22 May 2017 10:08:10 +0200 Subject: [PATCH 31/41] moved to java8 --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 8a075d7..ccd86df 100644 --- a/pom.xml +++ b/pom.xml @@ -103,8 +103,8 @@ UTF-8 UTF-8 UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 yyyy-MM-dd HH:mm:ssZ @@ -117,15 +117,15 @@ 1.7.22 1.1.9 - 2.2.19 + 2.2.20 1.8.9 - 4.3.7.RELEASE + 4.3.8.RELEASE 1.13.3.RELEASE 1.5.3.RELEASE 3.9.2 1.4.1 4.12 - 2.4.0 + 2.9.0 https://oss.sonatype.org/content/repositories/snapshots/ From fca7f05b2f04c45a4ea0e583340feaab502663e7 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 1 Jun 2017 17:42:40 +0200 Subject: [PATCH 32/41] updates to OrientDB 2.2.21 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ccd86df..e610e5c 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 1.7.22 1.1.9 - 2.2.20 + 2.2.21 1.8.9 4.3.8.RELEASE 1.13.3.RELEASE From e1aad887f238c99f6bbc090b1fd2fc9668222c85 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 1 Jun 2017 18:18:43 +0200 Subject: [PATCH 33/41] version set to 0.14 --- pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index e610e5c..4936c2b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index e419bd6..6e7bb85 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 203479c..4dda92c 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 416ad2c..31adaf8 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 02ba3e2..6ea49ae 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index 04af442..363f83f 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index d915f89..204103e 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 392a8aa..382d257 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index a4d8e3a..d1bc05e 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14-SNAPSHOT + 0.14 ../../pom.xml From 92241630279046375f63c628910d9314a090e533 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Fri, 2 Jun 2017 10:22:36 +0200 Subject: [PATCH 34/41] version bumped to 0.15-SNAPSHOT --- pom.xml | 2 +- spring-boot-orientdb-autoconfigure/pom.xml | 2 +- spring-data-orientdb-benchmarks/pom.xml | 2 +- spring-data-orientdb-commons/pom.xml | 2 +- spring-data-orientdb-document/pom.xml | 2 +- spring-data-orientdb-graph/pom.xml | 2 +- spring-data-orientdb-object/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml | 2 +- spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 4936c2b..51c22ea 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT pom Spring Data OrientDB diff --git a/spring-boot-orientdb-autoconfigure/pom.xml b/spring-boot-orientdb-autoconfigure/pom.xml index 6e7bb85..b5b3b82 100644 --- a/spring-boot-orientdb-autoconfigure/pom.xml +++ b/spring-boot-orientdb-autoconfigure/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-benchmarks/pom.xml b/spring-data-orientdb-benchmarks/pom.xml index 4dda92c..adc1750 100644 --- a/spring-data-orientdb-benchmarks/pom.xml +++ b/spring-data-orientdb-benchmarks/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-commons/pom.xml b/spring-data-orientdb-commons/pom.xml index 31adaf8..7aaa2d5 100644 --- a/spring-data-orientdb-commons/pom.xml +++ b/spring-data-orientdb-commons/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-document/pom.xml b/spring-data-orientdb-document/pom.xml index 6ea49ae..77a404a 100644 --- a/spring-data-orientdb-document/pom.xml +++ b/spring-data-orientdb-document/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-graph/pom.xml b/spring-data-orientdb-graph/pom.xml index 363f83f..90a054c 100644 --- a/spring-data-orientdb-graph/pom.xml +++ b/spring-data-orientdb-graph/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-object/pom.xml b/spring-data-orientdb-object/pom.xml index 204103e..534a2a2 100644 --- a/spring-data-orientdb-object/pom.xml +++ b/spring-data-orientdb-object/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml index 382d257..bffe30d 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-hello/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../../pom.xml diff --git a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml index d1bc05e..4005dbe 100644 --- a/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml +++ b/spring-data-orientdb-samples/spring-boot-orientdb-shiro/pom.xml @@ -5,7 +5,7 @@ com.orientechnologies spring-data-orientdb-parent - 0.14 + 0.15-SNAPSHOT ../../pom.xml From bef5edaba7cbf0c77c664247ccbfdc9602008da4 Mon Sep 17 00:00:00 2001 From: Roberto Franchini Date: Thu, 31 Aug 2017 14:07:36 +0200 Subject: [PATCH 35/41] fixes docker image name --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c831265..07cf693 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ #!groovy node("master") { def mvnHome = tool 'mvn' - def mvnJdk8Image = "orientdb/mvn-gradle-zulu-jdk-8:20161125" + def mvnJdk8Image = "orientdb/mvn-gradle-zulu-jdk-8" stage('Source checkout') { @@ -12,7 +12,7 @@ node("master") { docker.image("${mvnJdk8Image}").inside("${env.VOLUMES}") { try { - sh "${mvnHome}/bin/mvn --batch-mode -V -U clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" + sh "${mvnHome}/bin/mvn --batch-mode -V -U -fae clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" } catch (e) { currentBuild.result = 'FAILURE' From eb278216b659ecbd422db67fcc00e6ff55f0a99b Mon Sep 17 00:00:00 2001 From: Andrey Lomakin Date: Mon, 6 Nov 2017 11:56:30 +0200 Subject: [PATCH 36/41] Number of builds limited to 10 --- Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 07cf693..48fecaf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,9 @@ #!groovy node("master") { + properties([[$class: 'BuildDiscarderProperty', + strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', + artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10']]]) + def mvnHome = tool 'mvn' def mvnJdk8Image = "orientdb/mvn-gradle-zulu-jdk-8" From ac3272f8c5744dff4144030b8ccd09246203e1e2 Mon Sep 17 00:00:00 2001 From: Andrey Lomakin Date: Wed, 15 Nov 2017 19:30:44 +0700 Subject: [PATCH 37/41] 5GB memory limit is set --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 48fecaf..4fe6ed5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ node("master") { } stage('Run tests on Java8') { - docker.image("${mvnJdk8Image}").inside("${env.VOLUMES}") { + docker.image("${mvnJdk8Image}").inside("--memory=5g ${env.VOLUMES}") { try { sh "${mvnHome}/bin/mvn --batch-mode -V -U -fae clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" From e1a4a7ae6cd5f466d420c535d569118b37ffa037 Mon Sep 17 00:00:00 2001 From: Andrey Lomakin Date: Fri, 17 Nov 2017 13:14:07 +0700 Subject: [PATCH 38/41] Memory limit is set to 4GB --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4fe6ed5..fa5269f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,14 +13,14 @@ node("master") { } stage('Run tests on Java8') { - docker.image("${mvnJdk8Image}").inside("--memory=5g ${env.VOLUMES}") { + docker.image("${mvnJdk8Image}").inside("--memory=4g ${env.VOLUMES}") { try { sh "${mvnHome}/bin/mvn --batch-mode -V -U -fae clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" } catch (e) { currentBuild.result = 'FAILURE' - slackSend(color: 'bad', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") + slackSend(color: 'bad', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})\n${e}") } finally { junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml' From 1199662170bc6080600702a1507833c06f4ade27 Mon Sep 17 00:00:00 2001 From: Andrey Lomakin Date: Tue, 21 Nov 2017 18:55:35 +0700 Subject: [PATCH 39/41] Labels for docker monitoring were added --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa5269f..7f24252 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,13 @@ node("master") { def mvnHome = tool 'mvn' def mvnJdk8Image = "orientdb/mvn-gradle-zulu-jdk-8" + + def containerName = env.JOB_NAME.replaceAll(/\//, "_") + + "_build_${currentBuild.number}" + + def appNameLabel = "docker_ci"; + def taskLabel = env.JOB_NAME.replaceAll(/\//, "_") + stage('Source checkout') { @@ -13,7 +20,8 @@ node("master") { } stage('Run tests on Java8') { - docker.image("${mvnJdk8Image}").inside("--memory=4g ${env.VOLUMES}") { + docker.image("${mvnJdk8Image}").inside("--label collectd_docker_app=${appNameLabel} --label collectd_docker_task=${taskLabel} " + + "--name ${containerName} --memory=4g ${env.VOLUMES}") { try { sh "${mvnHome}/bin/mvn --batch-mode -V -U -fae clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" From b690f3ca32fa2fbbaa670784b5842ad933148fda Mon Sep 17 00:00:00 2001 From: laa Date: Thu, 23 Nov 2017 16:36:04 +0700 Subject: [PATCH 40/41] Memory locks were added --- Jenkinsfile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) mode change 100644 => 100755 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile old mode 100644 new mode 100755 index 7f24252..cd6091c --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,15 +1,15 @@ #!groovy node("master") { - properties([[$class: 'BuildDiscarderProperty', - strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', + properties([[$class : 'BuildDiscarderProperty', + strategy: [$class : 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10']]]) - + def mvnHome = tool 'mvn' def mvnJdk8Image = "orientdb/mvn-gradle-zulu-jdk-8" - - def containerName = env.JOB_NAME.replaceAll(/\//, "_") + + + def containerName = env.JOB_NAME.replaceAll(/\//, "_") + "_build_${currentBuild.number}" - + def appNameLabel = "docker_ci"; def taskLabel = env.JOB_NAME.replaceAll(/\//, "_") @@ -20,21 +20,21 @@ node("master") { } stage('Run tests on Java8') { - docker.image("${mvnJdk8Image}").inside("--label collectd_docker_app=${appNameLabel} --label collectd_docker_task=${taskLabel} " + - "--name ${containerName} --memory=4g ${env.VOLUMES}") { - try { + lock("label": "memory", "quantity": 4) { + docker.image("${mvnJdk8Image}").inside("--label collectd_docker_app=${appNameLabel} --label collectd_docker_task=${taskLabel} " + + "--name ${containerName} --memory=4g ${env.VOLUMES}") { + try { - sh "${mvnHome}/bin/mvn --batch-mode -V -U -fae clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" - } catch (e) { - currentBuild.result = 'FAILURE' + sh "${mvnHome}/bin/mvn --batch-mode -V -U -fae clean deploy -Dmaven.test.failure.ignore=true -Dsurefire.useFile=false" + } catch (e) { + currentBuild.result = 'FAILURE' - slackSend(color: 'bad', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})\n${e}") - } finally { - junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml' + slackSend(color: 'bad', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})\n${e}") + } finally { + junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml' + } } - - } } From 6b248a72f67860e432f44e5183f98cb6ea865319 Mon Sep 17 00:00:00 2001 From: Luigi Dell'Aquila Date: Thu, 3 Jan 2019 14:40:58 +0100 Subject: [PATCH 41/41] update spring-data and orientdb dependencies (security update) --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 51c22ea..a1b3464 100644 --- a/pom.xml +++ b/pom.xml @@ -117,10 +117,10 @@ 1.7.22 1.1.9 - 2.2.21 + 2.2.37 1.8.9 4.3.8.RELEASE - 1.13.3.RELEASE + 1.13.11.RELEASE 1.5.3.RELEASE 3.9.2 1.4.1