My Apache Cayenne query run 2 times when I run my container with Testcontainers. #31207
-
@bsideup
2-
@Slf4j
public class PostgresResource implements QuarkusTestResourceLifecycleManager
{
static PostgreSQLContainer<?> db = new PostgreSQLContainer<>("postgres")//
.withDatabaseName("test").withUsername("test").withPassword("test");
@Override
public Map<String, String> start()
{
db.start();
String connectionString = "jdbc:postgresql://" + db.getContainerIpAddress() + ":" + db.getFirstMappedPort() + "/" + db.getDatabaseName();
log.info("##Container started! connectionString: " + connectionString);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
log.info("****** DockerContainers stop******");
db.stop();
}));
return Collections.singletonMap("quarkus.datasource.jdbc.url", connectionString); //The same as above
}
@Override
public void stop()
{
db.stop();//Shut down the database after all tests have been executed
log.info("##Container stopped");
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think you probably need to debug your Apache Cayenne setup. |
Beta Was this translation helpful? Give feedback.
-
When I comment some modules in my context creator, The problem is solved: runtime = ServerRuntime.builder()
.dataSource(dataSource)
.addConfigs(config.configurationLocations())
.addModule(new ServerModule()) // added because of Native Imge
// .addModule(CommitLogModule.extend().commitLogAnnotationEntitiesOnly().addListener(cayenneCommitLogger).module()) //
.build();
// LifecycleCallbackRegistry registry = runtime.getDataDomain().getEntityResolver().getCallbackRegistry();
// for (Class<?> clazz : config.lockedClasses())
// registry.addCallback(LifecycleEvent.PRE_UPDATE, clazz, "preUpdate");
objectContext = runtime.newContext();
} |
Beta Was this translation helpful? Give feedback.
When I comment some modules in my context creator, The problem is solved: