Are tuples supported in the Java API?

Hi All,

I’m trying to learn how tuple schema types ( :db.type/tuple) are handled in the Java API. I see no mention of it anywhere. Can someone please point me in the right direction?


Nothing special in Java, API wise. Tuples are just Lists

The example from the docs works just fine:

public class TupleDemo {

    public final DatomicTestDb datomic = new DatomicTestDb("tupleDemo");

    public void tuplesWorkWithJava() throws ExecutionException, InterruptedException {
      ":db/ident", ":player/location",
                        ":db/valueType", ":db.type/tuple",
                        ":db/tupleTypes","[ :db.type/long :db.type/long]"),
                        ":db/cardinality", ":db.cardinality/one")


        Map txResult = datomic.connection().transact(Util.list(Util.list(":db/add", "newPlayer", ":player/location", Util.list(100L, 50L)))).get();

        Database db = (Database) txResult.get(Connection.DB_AFTER);
        Object newPlayerE = Peer.resolveTempid(

        Object locationTuple = Peer.query("[:find ?location . :where [?player :player/location ?location] :in $ ?player]", db, newPlayerE);

        assertThat((List)locationTuple).containsExactly(100L, 50L);



(If you want to run this, the @Rule above is just a test harness helper I have for crating mem dbs for testing, assertions provided by assertj)

Ahhh. I must have missed that example in the docs. This should get me started. Thanks Adam!

Well, maybe you didn’t, the docs example is written in clojure, so I just adapted from that for my post:

Anyway, tuples don’t really add any new data types on the API side, just schema.

OK, well that would explain it. I would, at the very least, have expected there to be a TYPE_TUPLE constant in the Attribute class. But there are no mentions of tuples anywhere at all that I can see! The Java API could use a spruce-up, but I’m good on my end thanks to the code snippet you gave me.

Thanks again!