DATAGRAPH-241 - base-package for entities, fix for alias lookup of loaded but not registered entities
requires an update of spring-data-commons to handle the initialization of the MappingContext in a later stage
This commit is contained in:
@@ -126,7 +126,7 @@
|
||||
<org.springframework.version.30>3.0.7.RELEASE</org.springframework.version.30>
|
||||
<org.springframework.version.40>4.0.0.RELEASE</org.springframework.version.40>
|
||||
<org.springframework.version>[${org.springframework.version.30}, ${org.springframework.version.40})</org.springframework.version>
|
||||
<data.commons.version>1.3.0.RC2</data.commons.version>
|
||||
<data.commons.version>1.3.1.BUILD-SNAPSHOT</data.commons.version>
|
||||
<neo4j.version>1.7</neo4j.version>
|
||||
<neo4j.spatial.version>0.8</neo4j.spatial.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
@@ -754,7 +754,10 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<url>http://repo.springsource.org/libs-milestone</url>
|
||||
<url>http://repo.springsource.org/libs-snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tinkerpop-repository</id>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.support.mapping;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.data.mapping.event.MappingContextEvent;
|
||||
@@ -24,17 +23,12 @@ import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
|
||||
import org.springframework.data.neo4j.support.Neo4jTemplate;
|
||||
import org.springframework.data.neo4j.support.index.IndexType;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
* @since 12.04.12
|
||||
*/
|
||||
public class IndexCreationMappingEventListener implements ApplicationListener<MappingContextEvent<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>>, InitializingBean {
|
||||
public class IndexCreationMappingEventListener implements ApplicationListener<MappingContextEvent<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>> {
|
||||
private Neo4jTemplate template;
|
||||
private Queue<Neo4jPersistentEntity> initialEntities=new ConcurrentLinkedQueue<Neo4jPersistentEntity>();
|
||||
private boolean isInitialized=false;
|
||||
public IndexCreationMappingEventListener(Neo4jTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
@@ -43,12 +37,7 @@ public class IndexCreationMappingEventListener implements ApplicationListener<Ma
|
||||
public void onApplicationEvent(MappingContextEvent<Neo4jPersistentEntity<?>, Neo4jPersistentProperty> event) {
|
||||
if (!(event.getSource() instanceof Neo4jPersistentEntity)) return;
|
||||
final Neo4jPersistentEntity entity = event.getPersistentEntity();
|
||||
if (!isInitialized) {
|
||||
initialEntities.add(entity);
|
||||
}
|
||||
else {
|
||||
ensureEntityIndexes(entity);
|
||||
}
|
||||
ensureEntityIndexes(entity);
|
||||
}
|
||||
|
||||
private void ensureEntityIndexes(Neo4jPersistentEntity entity) {
|
||||
@@ -63,13 +52,4 @@ public class IndexCreationMappingEventListener implements ApplicationListener<Ma
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
isInitialized = true;
|
||||
for (Neo4jPersistentEntity entity : initialEntities) {
|
||||
ensureEntityIndexes(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public class DataGraphNamespaceHandlerTest {
|
||||
Collection<Neo4jPersistentEntityImpl<?>> entities = config.mappingContext.getPersistentEntities();
|
||||
System.out.println(entities);
|
||||
assertTrue(entities.size() > 0);
|
||||
assertEquals(TestEntity.class, entities.iterator().next().getType());
|
||||
}
|
||||
@Test
|
||||
public void injectionForConversionService() {
|
||||
|
||||
@@ -14,33 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.neo4j.model;
|
||||
package org.springframework.data.neo4j.config;
|
||||
|
||||
import org.springframework.data.neo4j.annotation.GraphId;
|
||||
import org.springframework.data.neo4j.annotation.NodeEntity;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
* @since 18.02.11
|
||||
*/
|
||||
@NodeEntity
|
||||
public class Developer {
|
||||
String name;
|
||||
|
||||
Person spouse;
|
||||
|
||||
public Developer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Person getSpouse() {
|
||||
return spouse;
|
||||
}
|
||||
|
||||
public void setSpouse(Person spouse) {
|
||||
this.spouse = spouse;
|
||||
}
|
||||
public class TestEntity {
|
||||
@GraphId public Long id;
|
||||
}
|
||||
@@ -8,8 +8,8 @@
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||
|
||||
<context:annotation-config/>
|
||||
<neo4j:config storeDirectory="target/config-test" base-package="org.springframework.data.neo4j.model"/>
|
||||
<neo4j:config storeDirectory="target/config-test" base-package="org.springframework.data.neo4j.config"/>
|
||||
<bean id="config" class="org.springframework.data.neo4j.config.DataGraphNamespaceHandlerTest$Config"/>
|
||||
|
||||
<neo4j:repositories base-package="org.springframework.data.neo4j.model"/>
|
||||
<neo4j:repositories base-package="org.springframework.data.neo4j"/>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user