Consider I am developing a project which is about Vehicle. It is JavaFX desktop application. Classes exist in this projects are : Vehicle, Car and OffRoad. According to the OOP, abstraction
and design principles , Vehicle would be an Interface
and root of the hierarchy. Car also would be an Interface
and extends Vehicle
. OffRoad would be a class that implements Car. But from another point, I would like to use DAO Design Pattern to separate persistence layer from application. And In the Database I have a table named offroad. I map this table to the OffRoad class that implements Car Interface
; So OffRoad class would be a class with JPA Annotations
that implements Serializable
and Car Interfaces. Is it true so far? I mean Can I put my codes into OffRoad entity class which contains JPA Annotations
?
One of Main Question I have: Is the mapped class a java bean or a simple entity??!
I know that a java bean is a normal class with private fields, getters and setters method with public no argument constructor. If yes, Depending on the Java bean and Design Pattern roles, Can I implements Serializable
And Car in this class at the same time? We all know one of the JPA Persistence features is this that allow us to perform persistence class along with natural opp concepts.( Idiomatic persistence )
After that I should create an interface named something like OffRoadDAO that contains methods for CRUD Operations.
And after All a class that implements OfferDAO and permit us to use what we have made !
The Second main question is that Am I doing right?
Aucun commentaire:
Enregistrer un commentaire