所以我具有一个实体bean的Enum的属性:如何将Enum值作为字符串与Hibernate存储到SQL Server?
@Entity
@Table(name = "fileAttachment")
public class FileAttachment
// other properties..
@Enumerated(EnumType.STRING)
FileAttachmentType type;
// getters and setters
然而,当我坚持的豆,在该列中的值被示出为一个数字,如0或1或2。
如果我println
enum的值保持与EntityManager之前持续bean,值打印为字符串,如INVOICE
但在SQL Server表中该行的值为2,例如在fileAttachmentType列。我还需要配置什么?我认为EnumType.STRING
会做到这一点。
它由我在由LiquiBase运行的SQL脚本中创建。我发布了一个答案,我如何修复它。感谢您的建议 –