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

Table annotation shouldn't be mandatory #42

Open
NicolaIsotta opened this issue Feb 25, 2022 · 0 comments
Open

Table annotation shouldn't be mandatory #42

NicolaIsotta opened this issue Feb 25, 2022 · 0 comments

Comments

@NicolaIsotta
Copy link
Contributor

Right now, for CRUD operations, database table name is evaluated in this method:

/**
* Get the table name specified by the {@link Table} annotation.
*/
private void extractClassTableName() {
final Table tableAnnotation = clazz.getAnnotation(Table.class);
if (tableAnnotation != null) {
final String tableName = tableAnnotation.name();
this.tableName = tableName.isEmpty()
? clazz.getSimpleName() // as per documentation, empty name in Table "defaults to the entity name"
: tableName;
}
}

If the class does not have the @Table annotation, tableName is null and this could lead to various type of confusing exception from the jdbc drivers, such as: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'null'.

Is the a reason why this method does not default to clazz.getSimpleName() when there is no @Table annotation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant