Skip to content
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 Vert.x driver instead of JDBC #104

Closed
aguibert opened this issue May 1, 2020 · 28 comments
Closed

schema export via Vert.x driver instead of JDBC #104

aguibert opened this issue May 1, 2020 · 28 comments
Assignees
Labels
problem A limitation or source of discomfort
Milestone

Comments

@aguibert
Copy link
Contributor

aguibert commented May 1, 2020

Currently the RxPersistenceProvider does not have schema support, which means things like automatic table creation need to be done by JDBC.

It seems a bit awkward to require users to add/configure a JDBC driver if their app is only using RX. In theory we should be able to do all of the same schema generation using RxConnection instead of JDBC Connection.

@DavideD
Copy link
Member

DavideD commented May 1, 2020

It is a bit weird. At the same time I would prefer not to have too many ways to configure the same connection string. In the future a user will probably be able to use ORM with Rx and it might want to use the Rx API only in some cases. It is also nice that we use properties that are already familiar to an ORM user.

@DavideD
Copy link
Member

DavideD commented May 1, 2020

Ah sorry. I've just realized that you weren't talking about the property names.

@aguibert aguibert added the enhancement New feature or request label May 1, 2020
@DavideD
Copy link
Member

DavideD commented May 1, 2020 via email

@gavinking
Copy link
Member

Anyway, I guess we will have to have similar properties to the ORM ones but with thejdbc part removed from the name.

I think we should stick with the standard JDBC URL format because:

  • it's standard
  • it's well-documented by the database vendors
  • everyone already knows it
  • it makes it easier to configure Hibernate RX and plain Hibernate or plain JDBC at the same time

@aguibert
Copy link
Contributor Author

aguibert commented May 2, 2020

@DavideD I may have not properly described the issue in the OP, but how does config parameters come into play for schema gen?

To re-state the intent I had with this issue, I'm suggesting that the automatic drop/create table procedures can be done without needing to involve any JDBC drivers or jdbc-only config (if RX happens to re-use the same properties, that's fine though)

@DavideD
Copy link
Member

DavideD commented May 3, 2020

Ah sorry. I've just realized that you weren't talking about the property names.

Yeah, got it. My bad. I read it too quickly the first time.

It seems a bit awkward to require users to add/configure a JDBC driver if their app is only using RX.

This sentence here made me think you were talking about the fact that we use the properties for the JDBC configuration that already existis in ORM. It's still nice that we talked about it and I'm not planning to change them for now.

@gavinking
Copy link
Member

gavinking commented May 13, 2020

So previously I was arguing that doing the schema export over JDBC was perfectly fine. (What's a reactive schema export?)

However, in phone conversation with @emmanuelbernard and @Sanne, it's come to my attention that this is indeed actually a potential pain point for Quarkus users.

I should have paid more attention to @aguibert when he tried to warn me about this.

So, anyway, this is indeed an issue we should prioritize, though I suspect it can't be done in time for the initial release.

@gavinking gavinking added this to the NEXT milestone May 13, 2020
@gavinking gavinking added problem A limitation or source of discomfort and removed enhancement New feature or request labels May 13, 2020
@gavinking gavinking changed the title Schema gen support schema expert via Vert.x driver instead of JDBC May 13, 2020
@gavinking gavinking changed the title schema expert via Vert.x driver instead of JDBC schema export via Vert.x driver instead of JDBC May 13, 2020
@Sanne
Copy link
Member

Sanne commented May 13, 2020

weird idea - forgive me if it's silly as I don't really know - but wondering if we could wrap the reactive driver into a JDBC compatible adapter, then feed that into the schema gen code?

I guess such work would be overkill if it would just facilitate the schemagen tools, but perhaps there's more uses?

@gavinking
Copy link
Member

@Sanne

Well there is an abstraction here, called GenerationTarget. We might be able to implement that, though I'm not 100% sure exactly how one goes about plugging one in.

Failing that, one thing we might be able to do is ask the schema export tool to export a SCRIPT, and then just send the commands one-by-one to the DB.

@gavinking
Copy link
Member

We might be able to implement that, though I'm not 100% sure exactly how one goes about plugging one in.

The problem is that the list of these targets seems to be hardcoded, without any obvious way to add a new one. But a small fix to core might be enough to solve that.

@Sanne
Copy link
Member

Sanne commented May 13, 2020

Ok. While this is still not the top priority, I'll defer releasing the next ORM as much as feasible, so in case someone finds the time we can include some more last minute patches.

For reference, remember that performing the release really doesn' take us long: about 20 minutes. But then we need to wait for Maven central synchronization and all that before it can actually be used :(
Which implies we need to release about 24h before a Reactive release is possible.

@gavinking
Copy link
Member

I'll set aside some time to attempt this. Perhaps it's super-simple. We'll find out.

@gavinking
Copy link
Member

Perhaps it's super-simple. We'll find out.

So, indeed, it was relatively straightforward, but it raised an issue I hadn't considered: Hibernate Reactive no longer has access to JDBC metadata, which does have some consequences, but I don't think they're too terrible. Fortunately Hibernate was written when JDBC metadata was very unreliable, and doesn't really depend on it.

I guess that's OK.

Also it exposed a bug in ForeignKeys where Hibernate Reactive would actually use the JDBC connection to obtain snapshots from the database! I will open a separate bug report for that problem.

@gavinking gavinking modified the milestones: NEXT, FIRST CUT May 13, 2020
@gavinking gavinking linked a pull request May 13, 2020 that will close this issue
@Sanne
Copy link
Member

Sanne commented May 13, 2020

Awesome, thanks!

@Sanne
Copy link
Member

Sanne commented May 13, 2020

Gavin's fix was merged in ORM; schema creation should be doable now.

I suspect automated schema update is a fair bit more complicated though - can we agree that's less important for the first cut?

@gavinking
Copy link
Member

Gavin's fix was merged in ORM; schema creation should be doable now.

Thanks.

I suspect automated schema update is a fair bit more complicated though

Oh, much more difficult, since the current implementation is entirely based on JDBC metadata, IIRC.

can we agree that's less important for the first cut?

Yeah, I have no intention at all of working on that at this stage. Nor do I think it's needed.

@gavinking
Copy link
Member

@Sanne how long before we get a release of ORM core with that change in it?

@Sanne
Copy link
Member

Sanne commented May 14, 2020

@gavinking we can plan a release on Monday. I wonder though - if there's more changes possibly needed maybe it's best to defer?
We're also working on some other fixes that Quarkus needs - so while we can releas one whenever we like, the later the more fixes.

@gavinking
Copy link
Member

gavinking commented May 14, 2020

@Sanne No hold tight, that comment was made before I discovered the seriousness of #113.

@aguibert
Copy link
Contributor Author

@gavinking at some point could you write up an issue on Vertx-sql-client outlining what sorts of DB metadata is needed by Hibernate? The Vertx client should have a better metadata API than it currently does someday.

@BillyYccc
Copy link

BillyYccc commented May 14, 2020 via email

@gavinking
Copy link
Member

What the schema management tools needs is access to the information in information_schema.tables and I guess also information_schema.key_column_usage.

@gavinking
Copy link
Member

What the schema management tools needs is access to the information in information_schema.tables and I guess also information_schema.key_column_usage.

Note that one option is for it to get that information directly by querying the information_schema. Historically it just the JDBC metadata API for that, in order to abstract away from platform differences.

@gavinking
Copy link
Member

gavinking commented May 18, 2020

This is done!

And it's done in a way that's pretty transparent to the user: if they have a JDBC driver or connection pool set up, then Hibernate ORM will do the schema export over JDBC but iff they don't have a JDBC driver, then schema export over the Vert.x driver will kick in.

@DavideD
Copy link
Member

DavideD commented May 18, 2020

That's awesome!
Thanks a lot

@Sanne
Copy link
Member

Sanne commented May 18, 2020

And it's done in a way that's pretty transparent to the user: if they have a JDBC driver or connection pool set up, then Hibernate ORM will do the schema export over JDBC but iff they don't have a JDBC driver, then schema export over the Vert.x driver will kick in.

just curious, why should it try to use the JDBC approach first? If we have the capability to run it over vertx, why not do it always?

It might get confusing to users if there's different behaviours being triggered just because some unrelated connection is being setup. Also - how do you know if that other connection really points to the same DB?

@gavinking
Copy link
Member

just curious, why should it try to use the JDBC approach first? If we have the capability to run it over vertx, why not do it always?

Well if you have regular Hibernate right there set up with a regular JDBC driver why not use it? Reactive schema export isn't a meaningful thing. To make this even work we have to do a totally nasty join() at the end, which Vert.x find quite upsetting.

@gavinking
Copy link
Member

how do you know if that other connection really points to the same DB?

Cos it's the same JDBC URL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem A limitation or source of discomfort
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants