• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[JPA - Hibernate] Mapping Enum to Column

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an Enum:



And then I have the following Entity class:



In order for the productAttributeFormType to just have its value in a column is it as simple as:

@Column(name="FormType")
private ProductAttributeFormType productAttributeFormType;

Or is there more to it?

Thanks,
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ran across this. A bit more to it than I though but makes sense.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On further inspection, I'm not sure that will work for my use case. So still looking for answers.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, after some testing, this appears to work...

@Enumerated(value = EnumType.STRING)
private ProductAttributeType productAttributeType;
 
Rodrigo Lopes
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's the way
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic