This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I am using Enumerated.oridnal in the PK class to insert an integer field in the mysql database.
Now i read somewhr that enum sholud not used to build the composite primary key..
Can any one suggest me whtr i can use enum as one of the datatype to build composite primary key...
In my java code i am maintaining a Enum constants with 3 values...
i need to insert the ordinal values of the corresponding enum into the databse.The type of that field is integer.Its one of the field i used to construct the composite primary key
Thats means in a table there are 3 fields used as primary keys and this ordinal is one of the primary keys used to construct the composite primary key...
so while creating entity class for this one, i should mention the three primary in an separate PK class. In that i should declare the field as typr NUMBER with the Annotation @Enumnerated(Enum.Ordinal)..but we are mapping the integer value to that integer field in database..
Now i need to clarify that is it good pratice to use Annotation @Enumnerated(Enum.Ordinal) in the PK Class..