• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

My exam cloud mock exam 1 , about @Enumerated

 
Ranch Hand
Posts: 1749
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, in my exam cloud mock exam 1,


11.public enum CustomerType{INDIVIDUAL, CORPORATE}
12.public enum OfferPercent{FIFTY, FOURTY}
13. @Entity public class Customer{...}
...
20.
21.public OfferPercent getOfferPercent(){...}
22.@Enumberated(STRING)
23.public CustomerType getCustomerType(){...}
...
30. }

Assume that the customer type property is mapped to a column of integer type, and the offer percent property to a column of varchar type.



I think line 22 in the code should be @Enumerated(INTEGER) because the customer type is mapped to a column of integer type.

Or, in another way,  the customer type should be mapped to a column of varchar type instead of integer type if @Enumerated(STRING) is used in line 22.
 
Creator of Enthuware JWS+ V6
Posts: 3293
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree.

  • Bad placement of the annotation, should go to line 20.
  • typo @Enumberated should be @Enumerated
  • Wrong EnumType on line 22, should be @Enumerated(ORDINAL)
  •  
    Himai Minh
    Ranch Hand
    Posts: 1749
    12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The typo "@Enumberated " is actually my fault, not from my exam cloud.
    Question: Which of the followings are legal for line 20?

    I think line 20 should be @Enumerated(STRING).
    The options provided are:
    A. @Enumerated(Integer)
    B. @Enumerated(ORDINAL)
    C. @Enumerated()
    D. @Enum

    The given answers are B, C
    I think line 20 should be @Enumerated(String) because offerPercent is a varchar , which is a string.
     
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Posts: 3293
    296
    Android Eclipse IDE Chrome
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yeah, both B and C are legal but will result in an integer type.
     
    Himai Minh
    Ranch Hand
    Posts: 1749
    12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi for everyone's reference. I modified chapter 4's enumMapping into 4 different cases:
    case 1:

    The Employee table has a column TYPE of varchar(255).
    The column shows FULL_TIME_EMPLOYEE in the DB.

    Case 2:

    The employee table still has column TYPE of  varchar (255)
    Column shows 0 (type cast from integer to string)


    case 3:

    The employee table has column TYPE of int (11)
    Column shows 0

    case 4:

    The employee table has column TYPE of int (11)
    Runtime error occurs : Internal exception: java.sql.SQLException: Incorrect integer value.
     
    This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
    Enterprise-grade Excel API for Java
    https://products.aspose.com/cells/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!