Datomic从Java插入数据库

时间:2016-04-27 14:35:01

标签: sql insert datomic

拥有这个架构notaCurs,我想从java代码插入数据库。 :notaCurs / student是对另一个模式的引用,并且:notaCurs / curs也是对另一个模式的引用。我能够查询我的数据库,但是不能执行任何删除,更新和插入。只选择执行。

{:db/id #db/id[:db.part/db]
  :db/ident :notaCurs/student
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one
  :db/doc "Student"
  :db.install/_attribute :db.part/db}

 {:db/id #db/id[:db.part/db]
  :db/ident :notaCurs/curs
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one
  :db/doc "Curs"
  :db.install/_attribute :db.part/db}

 {:db/id #db/id[:db.part/db]
  :db/ident :notaCurs/nota_laboratory
  :db/valueType :db.type/bigdec
  :db/cardinality :db.cardinality/one
  :db/doc "Nota laborator"
  :db.install/_attribute :db.part/db}

 {:db/id #db/id[:db.part/db]
  :db/ident :notaCurs/nota_examen
  :db/valueType :db.type/bigdec
  :db/cardinality :db.cardinality/one
  :db/doc "Nota examen"
  :db.install/_attribute :db.part/db}

  {:db/id #db/id[:db.part/db]
  :db/ident :notaCurs/nota_final
  :db/valueType :db.type/bigdec
  :db/cardinality :db.cardinality/one
  :db/doc "Nota finala"
  :db.install/_attribute :db.part/db}

我尝试执行的插入是

 Long idCurs = 1223232324L;
   Long idStudent = 34335345345L;
   BigDecimal nota1 = new BigDecimal(5);
   BigDecimal nota2 = new BigDecimal(6);

List add_nota_tx = Util.list(Util.map(Util.read(":db/id"), Peer.tempid(":db.part/user") , ":notaCurs/curs", idCurs, ":notaCurs/student", idStudent, ":notaCurs/nota_examen", nota1, ":notaCurs/nota_laboratory", nota2));


        try {
            Object txResult = c.transact(add_nota_tx).get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

它不会在stacktrace上打印任何错误。任何帮助将不胜感激。

L.E。这条线有助于当时:

        db = (Database) txResult.get(Connection.DB_AFTER); 

0 个答案:

没有答案