AOT contribution for @PersistenceContext and @PersistenceUnit

Closes gh-28364
This commit is contained in:
Stephane Nicoll
2022-04-21 17:01:40 +02:00
parent 10d254983f
commit 26054fd3d4
8 changed files with 491 additions and 22 deletions

View File

@@ -44,6 +44,16 @@ public final class MultiStatement {
return this.statements.isEmpty();
}
/**
* Add the statements defined in the specified multi statement to this instance.
* @param multiStatement the statements to add
* @return {@code this}, to facilitate method chaining
*/
public MultiStatement add(MultiStatement multiStatement) {
this.statements.addAll(multiStatement.statements);
return this;
}
/**
* Add the specified {@link CodeBlock codeblock} rendered as-is.
* @param codeBlock the code block to add

View File

@@ -150,4 +150,17 @@ class MultiStatementTests {
"}");
}
@Test
void addWithAnotherMultiStatement() {
MultiStatement statements = new MultiStatement();
statements.addStatement(CodeBlock.of("test.invoke()"));
MultiStatement another = new MultiStatement();
another.addStatement(CodeBlock.of("test.another()"));
statements.add(another);
assertThat(statements.toCodeBlock().toString()).isEqualTo("""
test.invoke();
test.another();
""");
}
}