Hello everyone: I am new to ORM, Hibernate and JPA. I have learnt some hibernate and jpa knowledge from two books I bought recently. One is the "Hibernate made easy" and the other is the "Java Persistence with Hibernate". I am currently developing my own web applications, and currently I am working on the ORM part. Since I am pretty new to Hibernate, I hope to get some help from all the experts around here. Alright, here my question is. If I am building an option to let online users select ways of paying for a certain service (e.g. 15 USD/month ), what would be the best way to map the tables with java objects? My personal idea would be to create a table for the service that is being selected based on, maybe called "services", with a java class called "Service". Within this "services" table, I create 2 fields, one is the Primary key (id), the other is the Foreign key referencing to the PK of another table called "charge_methods" which is mapped by a Java class called "ChargeMethod". There are 3 fields in the "charge_methods" table; they are "amount"(15), "currency"(USD) and "payPeriod"(Month). By doing this way, I assume I will have to create hibernate custom mapping type for "currency" and "payPeriod", because each of these 2 is also a Java Enumeration containing different currency and pay period, such as USD, CAD, EUR for the currency field and Month, Year, Day for the pay period. My question is if I really do this way, do I really need to create custom mapping type even if I use JPA? Do mapping Java Enumeration always require custom mapping? if this way is not recommended, what would you suggest?
Much appreciated!
Phil
|