Home How to persist an enum with JPA?
Reply: 0

How to persist an enum with JPA?

user751
1#
user751 Published in June 23, 2018, 4:32 am

I'm using MySQL and JPA.

I have an enum that has it's own table.

I have a field in an entity (entity1) that uses this enum. This field is annotated with: @Enumeration(EnumType.STRING).

1 - is it correct to persist this field in entity1 as a column in the db when it has it's own table?

2 - if I am using @JsonProperty on my other fields and answer to 1 is "yes", must I use @JsonProperty on the enum field too?

3 - what's the point in having the enum in a separate table?

Currently, with just the @Enumeration annotation and a column for the enum for entity1 I get error: was annotated as enumerated, but its java type is not an enum

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.318467 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO