adding support for selective column writes#8
Conversation
|
|
||
| @Override | ||
| public <T> T save(T entity, List<String> selectedFields) { | ||
| Connection conn = null; |
There was a problem hiding this comment.
If connection is auto-closable you can use try with resources
There was a problem hiding this comment.
For now keeping it simple and consistent with the other apis implementations
| * @param selectedFields | ||
| * @return | ||
| */ | ||
| <T> T save(T entity, List<String> selectedFields); |
There was a problem hiding this comment.
Consider renaming to something like partial update
| <T, R> R findOne(QuerySelect<T, R> query); | ||
|
|
||
| /** | ||
| * Save selective field for the given entity |
There was a problem hiding this comment.
Clarify the JavaDoc to indicate that this updates an existing entity, but only for the selected fields.
| * @param selectedFields | ||
| * @return | ||
| */ | ||
| <T> T save(T entity, List<String> selectedFields); |
There was a problem hiding this comment.
Consider using Collection or Set instead of List
There was a problem hiding this comment.
underlying QuerySelectImpl supports List. Being consistent with that and not having to convert from Set to List.
| * | ||
| * @param entity | ||
| * @param selectedFields | ||
| * @return |
There was a problem hiding this comment.
Note that the returned value is the saved value. Not if it can ever be null.
| /** | ||
| * Save selective field for the given entity | ||
| * | ||
| * @param entity |
There was a problem hiding this comment.
Note if the entity must already exist
|
|
||
| /** | ||
| * Save selective field for the given entity | ||
| * |
There was a problem hiding this comment.
Write what happens if the save fails
There was a problem hiding this comment.
A runtime exception is thrown if the save fails. I think documenting that would be a little odd as any method could throw a Runtime exception.
| conn.commit(); | ||
| return returnEntity; | ||
| } catch (Exception ex) { | ||
| throw new RuntimeException(ex); |
There was a problem hiding this comment.
I would let the consumer of this api log the message. Exception handling is the responsibility of the consumer.
|
👍 |
No description provided.