For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
public enum BookCategory {MYSTERY, SCIENCE_FICTION, BIOGRAPHY}
public class BookCategoryFieldTransformer extends FieldTransformerAdapter { @Override public Object buildFieldValue(Object object, String fieldName, Session session) { Book book = (Book)object; BookCategory category = book.getCategory(); if (category != null) { return category.name(); } else { return null; } } }
// the database field CATEGORY contains a string obtained from an Enum using the name() method public class BookCategoryAttributeTransformer extends AttributeTransformerAdapter { @Override public Object buildAttributeValue(Record record, Object object, Session session) { return BookCategory.valueOf((String)record.get("CATEGORY")); } }