在 Clojure 谷歌支持小组上发布这个似乎对我不起作用,所以我会尝试在这里提问。
我正在运行以下稍作修改的 GettingStarted.java(来自 clojure 发行版)作为 Spring 配置的测试,以查看 Datomic 如何集成到我的应用程序中,并且在下面的第一个 Peer.q 调用中没有得到任何结果(而相同的控制台调用返回 150 条记录)。我在这里做错了什么,请帮忙?
@ContextConfiguration(classes={GettingStartedConfig.class}, loader=AnnotationConfigContextLoader.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class GettingStartedTest {
private final Logger log = LoggerFactory.getLogger(getClass());
private static final Scanner scanner = new Scanner(System.in);
private String uri = "datomic:mem://seattle";
@Autowired
private Reader schema;
@Autowired
private Reader seed0;
private void pause() {
if (System.getProperty("NOPAUSE") == null) {
log.info("\nPress enter to continue...");
scanner.nextLine();
}
}
@SuppressWarnings("rawtypes")
@Test
public void test() throws Exception {
log.info("Creating and connecting to database...at {}", uri +"\n\n");
Peer.createDatabase(uri);
Connection conn = Peer.connect(uri);
pause();
log.info("Parsing schema dtm file and running transaction...\n\n");
log.info("schema: "+schema);
List schema_tx = (List) Util.readAll(schema).get(0);
schema.close();
Object txResult = conn.transact(schema_tx).get();
log.info("result of schema transaction: "+txResult);
pause();
log.info("Parsing seed data dtm file and running transaction...\n\n");
List data_tx = (List) Util.readAll(seed0).get(0);
seed0.close();
txResult = conn.transact(data_tx).get();
pause();
log.info("Finding all communities, counting results...\n\n");
Collection results = Peer.q("[:find ?c :where [?c :community/name]]", conn.db());
log.info("size of the result = {} " , results.size() + "\n\n");
pause();
...................................
[main] INFO com.excelsiorsoft.daedalus.persistence.datomic.GettingStartedTest - 查找所有社区,计算结果...
[main] INFO com.excelsiorsoft.daedalus.persistence.datomic.GettingStartedTest - 结果大小 = 0
提前感谢您帮助我。