BugFix: Allow non-primary-key generated fields, e.g. timestamps, counters, etc. #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, HibernateD treats
@Generated
as being inseparable from@Id
, it is assumed that any generated field is also the primary key.However, a database table can have non-primary-key columns that are
@Generated
. For example, a database that keeps track of a timestamp, which is populated via a DB trigger or a default value, e.g.now()
, may exist alongside a separate primary key.In order to support this kind of data, the assumption that
@Generated
implies@Id
needs to be undone. This PR changes the core logic and also adds a basic test around generated columns to validate schema generation as well as the ability to insert and update such records.