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

SqlValue interface for ArgPreparedStatementSetter [SPR-4558] #9235

Closed
spring-projects-issues opened this issue Mar 8, 2008 · 3 comments
Closed
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 8, 2008

Stepan Koltsov opened SPR-4558 and commented

Spring should have


interface SqlValue {
Object getSqlValue();
}


and StatementCreatorUtils.setParameterValueInternal should have:


if (value instanceof SqlValue) value = ((SqlValue) value).getSqlValue();


This is needed for implicit conversion of some types to SQL values.

In our projects we have SqlValue interface and we've reimplemented ArgPreparedStatementSetter that to SqlValue. And we've made all our DB-related enums (and some other classes) implement SqlValue. Example:


enum UserState implement SqlValue {
UNKNOWN(0),
WAITING_FOR_MODERATION(1),
AVAILABLE(2),
DELETED(3),
BLOCKED(4);
final int value;
Object getSqlValue() { return value; }
}

void updateUserState(long userId, UserState state) {
getSimpleJdbcTemplate().update("UPDATE users SET state = ? WHERE user_id = ?", state, userId);
// instead of
getSimpleJdbcTemplate().update("UPDATE users SET state = ? WHERE user_id = ?", state.value(), userId);
}



Affects: 2.5.2

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 8, 2008

Stepan Koltsov commented

relates to #8658, #8657

@spring-projects-issues
Copy link
Collaborator Author

Stepan Koltsov commented

Oops, I've found that SqlTypeValue exists. So won't fix, please.

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

This issue has been resolved through a selective bulk update, as part of a larger effort to better manage unresolved issues. To qualify for the update, the issue was either created before Spring 3.0 or affects a version older than Spring 3.0 and is not a bug.

There is a good chance the request was made obsolete, or at least partly outdated, by changes in later versions of Spring including deprecations. It is also possible it didn't get enough traction or we didn't have enough time to address it. One way or another, we didn't get to it.

If you believe the issue, or some aspects of it, are still relevant and worth pursuing at present you may re-open this issue or create a new one with a more up-to-date description.

We thank you for your contributions and encourage you to become familiar with the current process of managing Spring Framework JIRA issues that has been in use for over a year.

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant