package io.quarkus.jdbc.h2.runtime.graal;

import org.h2.engine.ConnectionInfo;
import org.h2.engine.Session;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "org.h2.engine.Engine")
@Substitute
public final class Engine {

    @Substitute
    public Session createSession(ConnectionInfo ci) {
        throw new UnsupportedOperationException(
                "H2 database compiled into a native-image is only functional as a client: can't create an Embedded Database Session");
    }

    @Substitute
    void close(String name) {
        //no-op
    }

}

@@ -104,16 +104,58 @@
 ssion;%0A%0A
+import com.oracle.svm.core.SubstrateUtil;%0A
 import c
@@ -334,16 +334,171 @@
 gine %7B%0A%0A
+    @Substitute%0A    public static org.h2.engine.Engine getInstance() %7B%0A        return SubstrateUtil.cast(new Engine(), org.h2.engine.Engine.class);%0A    %7D%0A%0A
     @Sub

Fix H2 native DeletedElementException