-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schema export via reactive driver #112
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
hibernate-rx-core/src/main/java/org/hibernate/rx/service/RxDummyConnectionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.hibernate.rx.service; | ||
|
||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
|
||
public class RxDummyConnectionProvider implements ConnectionProvider { | ||
@Override | ||
public Connection getConnection() throws SQLException { | ||
throw new SQLException("Not using JDBC"); | ||
} | ||
|
||
@Override | ||
public void closeConnection(Connection conn) {} | ||
|
||
@Override | ||
public boolean supportsAggressiveRelease() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isUnwrappableAs(Class unwrapType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public <T> T unwrap(Class<T> unwrapType) { | ||
return null; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
hibernate-rx-core/src/main/java/org/hibernate/rx/service/RxGenerationTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.hibernate.rx.service; | ||
|
||
import org.hibernate.rx.service.initiator.RxConnectionPoolProvider; | ||
import org.hibernate.service.ServiceRegistry; | ||
import org.hibernate.tool.schema.internal.exec.GenerationTarget; | ||
|
||
/** | ||
* Adaptor that redirects DDL generated by the schema export | ||
* tool to the reactive connection. | ||
* | ||
* @author Gavin King | ||
*/ | ||
public class RxGenerationTarget implements GenerationTarget { | ||
RxConnection connection; | ||
private ServiceRegistry registry; | ||
|
||
public RxGenerationTarget(ServiceRegistry registry) { | ||
this.registry = registry; | ||
} | ||
|
||
@Override | ||
public void prepare() { | ||
connection = registry.getService( RxConnectionPoolProvider.class ).getConnection(); | ||
} | ||
|
||
@Override | ||
public void accept(String command) { | ||
try { | ||
connection.preparedQuery(command).toCompletableFuture().join(); | ||
} | ||
catch (Exception e) { | ||
System.out.println( e.getMessage() ); | ||
} | ||
} | ||
|
||
@Override | ||
public void release() { | ||
connection.close(); | ||
connection = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vietj @FroMage @Sanne @DavideD WDYT of this?
I want to run Schema Export against the Vert.x driver, but I don't need it to actually be reactive. Also, I don't want to rewrite all of Hibernate's schema export stuff to use
CompletionStage
or whatever.This seems to work fine, except with the
@RunWith(VertxUnitRunner.class)
where sometimes I get a harmless stacktrace from Vert.x at the end of my test.Is this for some reason a terrible thing to be doing? Is there some other way we should be doing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavinking What's the stack trace complaining about? Is it the Vertx blocked thread checker? If that's the case, I think we can safely ignore that because we are intending to be blocking here. To silence the blocked thread checker, we could use our own
Vertx
instance where we can set the blocked thread checker interval to a really high value like so:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it looks to me like Vert.x shuts down the thread because it thinks it's misbehaving.
Let's try your suggestion. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aguibert so I looked for a place to set this up in
VertxUnitRunner
and didn't find anything obvious. @vietj any suggestion?