Skip to content

版本2.2.16在新增的时候,如果主键是自增的,通过什么方式可以获取到那个自增后的id呢?使用的sdk版本是:java #34032

Closed Answered by yhmo
mmahao asked this question in Q&A and General discussion
Discussion options

You must be logged in to vote
R<MutationResult> insertR = client.insert(InsertParam.newBuilder()
        .withCollectionName(collectionName)
        .withFields(fields)
        .build());

MutationResultWrapper insertResultWrapper = new MutationResultWrapper(insertR.getData());
System.out.println(insertResultWrapper.getInsertCount() + " rows inserted");
List<Long> ids = insertResultWrapper.getLongIDs(); // get returned IDs(generated by server-side)

Replies: 5 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mmahao
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mmahao
Comment options

Answer selected by mmahao
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants