jSQL-Gen
jSQL-Gen copied to clipboard
Reusable enums / Inter-table enums
To prevent ugly stuff like this:
Review.Rating rating = values[i];
List<ReviewRating> reviewRatings = ReviewRating.whereReviewId().is(review.id)
.and(ReviewRating.whereRating().is(ReviewRating.Rating.valueOf(rating.name()))).get();
Instead, it could look like this if the enum was imported instead of redefined in the other table:
Review.Rating rating = values[i];
List<ReviewRating> reviewRatings = ReviewRating.whereReviewId().is(review.id)
.and(ReviewRating.whereRating().is(rating).get();
Details: We have a enum named Rating defined twice in the Review table and the ReviewRating table even though its exactly the same enum used.