Skip to content

adding support for selective column writes#8

Merged
vvangapandu merged 2 commits into
masterfrom
SFT-21215
Nov 3, 2016
Merged

adding support for selective column writes#8
vvangapandu merged 2 commits into
masterfrom
SFT-21215

Conversation

@suneetapuranik

Copy link
Copy Markdown
Collaborator

No description provided.


@Override
public <T> T save(T entity, List<String> selectedFields) {
Connection conn = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If connection is auto-closable you can use try with resources

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For now keeping it simple and consistent with the other apis implementations

* @param selectedFields
* @return
*/
<T> T save(T entity, List<String> selectedFields);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider renaming to something like partial update

<T, R> R findOne(QuerySelect<T, R> query);

/**
* Save selective field for the given entity

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clarify the JavaDoc to indicate that this updates an existing entity, but only for the selected fields.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

* @param selectedFields
* @return
*/
<T> T save(T entity, List<String> selectedFields);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider using Collection or Set instead of List

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

underlying QuerySelectImpl supports List. Being consistent with that and not having to convert from Set to List.

*
* @param entity
* @param selectedFields
* @return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note that the returned value is the saved value. Not if it can ever be null.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

/**
* Save selective field for the given entity
*
* @param entity

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note if the entity must already exist

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done


/**
* Save selective field for the given entity
*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Write what happens if the save fails

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we log this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I would let the consumer of this api log the message. Exception handling is the responsibility of the consumer.

@vvangapandu

Copy link
Copy Markdown
Contributor

👍

@vvangapandu vvangapandu merged commit 0316917 into master Nov 3, 2016
@vvangapandu vvangapandu deleted the SFT-21215 branch November 3, 2016 20:21
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

Successfully merging this pull request may close these issues.

3 participants