Can not explore database created by an embedded neo4j

一笑奈何 提交于 2019-12-11 06:59:36

问题


I encounter a strange problem.

I created an database using embedded neo4j whose path is "/Users/bondwong/Documents/workspace/pamela/target/data/pamela.db".

Here is the Spring configuration:

<bean id="graphDbBuilder" factory-bean="graphDbFactory"
    factory-method="newEmbeddedDatabaseBuilder">
    <constructor-arg value="target/data/pamela.db" />
</bean>

Then I changed this line of neo4j-server.properties:

org.neo4j.server.database.location=/Users/bondwong/Documents/workspace/pamela/target/data/pamela.db

After that, I used curl to test my system, which showed all is good. Here is the result of getting a node whose id is 9:

However, when I fired up the server, and use the browser to see the data, nothing shows up:

Here is the location, it is the same as the one in the Spring XML configuration file:

Here is the :sysinfo result:

Here is the jUnit test and its result, showing that it actually insert the data:

package repositoryTest;

import static org.junit.Assert.*;

import java.util.HashMap;

import org.junit.Test;
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 com.bond.pamela.domain.Diary;
import com.bond.pamela.domain.factory.DiaryFactory;
import com.bond.pamela.persistence.DirayRepository;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "/applicationContext.xml" })
public class DiaryRepositoryTest {
    @Autowired
    DirayRepository repository;

    @Test
    @Transactional
    public void testSaveDiary() {
        Diary diary = (Diary) DiaryFactory.getInstance().create(
                new HashMap<String, Object>());
        repository.save(diary);

        Diary retrivedDiary = repository.findOne(diary.getGraphId());
        assertEquals(diary, retrivedDiary);
    }

}

I think it should work, someone knows what is wrong? and how to fix it. Thx!


回答1:


You can write your java code as server extension

or use WrappingBootstrapper for the time being. Or rather use ServerControls from Neo4j-Harness for testing

When creating the data, are you sure you committed the transaction correctly?

Transaction tx = db.beginTx();
// create data
tx.success(); 
tx.close();

or better

try (Transaction tx = db.beginTx()) {
  // create data
  tx.success(); 
}


来源:https://stackoverflow.com/questions/31177054/can-not-explore-database-created-by-an-embedded-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!