java - Hibernate Enum mapping using annotaions -
I have an existing database that is now connecting to using hibernate I do not change this data at the moment May be able to do everything except the one column.
I have a status column, which contains the values:
- New
and the column is mapped as follows:
@column (name = "condition", drain = False, length = 50) @ Nominated (enumotype pillar) private teammemberstats status;
I really want to map this column as Java Enum (for application reasons), but due to the fact that 'new' in Java One keyword is I can not do as an enum member.
If I have anman contstants, in myriad, in and out of the passive form EnumType fails inside it, it does an Enum.valueOf ().
Is there any way to mapping it in my anonymity to write a complex user note?
- Added content
My anomimas like this:
public enum TeamMemberStatus {NEW, MAILED, IN, OUT}
is a valid Java enumeration, but does not match the case of the database. If I change it to match it to the database:
Public Anonymous TeammailStatus {new, mail, in, out}
This 'new' Is a reserved word java.
If you can use a SQL UPPER statement in the database, It will work without using any user type
UPDATE
Well, this can not be the best solution, but this is what you want Resolve
@ Entity Public Square Ring (Private TeammemberStatus Subscription Manager; @transient Private TeammemberStatus MembersStatus) Public Zero SatmemberStatus (TeammemberStatus Subscriber) {this.memberStatus = memberStatus;} @column (name = "condition", falsifiable = false, length = 50) Public string mixerstats eststrung () {Return member status.name ( ). ToLowerCase ();} Public Zero setmemberstastststring (string membersstats) {This sitemastersstats (TeamMustStatus.viewOff (memberStatus.UpperCase ());}
}
Comments
Post a Comment