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

propose @DialectOverride annotation #4537

Closed
wants to merge 2 commits into from

Conversation

gavinking
Copy link
Member

This allows the use of native SQL in annotations of portable programs.

We've needed something like this for a long time.

@@ -94,7 +96,8 @@ void tearDown(SessionFactoryScope scope) {

private Double rate;

@Formula(value = "credit * rate")
@Formula(value = "credit * rate",
overrides = @DialectOverride(dialect = H2Dialect.class, value ="rate * credit") )
private Double interest;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example of how you might use it, but it's much more general than this.

@gavinking
Copy link
Member Author

gavinking commented Dec 29, 2021

Currently the API for this looks like:

@Formula(value = "credit * rate",
	overrides = @DialectOverride(dialect = H2Dialect.class, value = "rate * credit") )

I guess an alternative way to do it, that has less impact on the existing annotations, would be to write:

@Formula(value = "credit * rate")
@DialectOverride(annotation = Formula.class, dialect = H2Dialect.class, value = "rate * credit")

I'm unclear on which option is "better". I guess they're pretty equivalent.

Copy link
Contributor

@beikov beikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, but let's discuss the design first in #4528

This allows the use of native SQL in annotations of portable programs.

We've needed something like this for a long time.
@gavinking
Copy link
Member Author

Superseded by #4607.

@gavinking gavinking closed this Jan 20, 2022
@gavinking gavinking deleted the dialect-override branch June 15, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants