I am trying to create an application which will be partially d开发者_运维技巧ependent on the Census Department TIGER/Lines data Shapefiles, which have a record layout defined here:
http://www.census.gov/geo/www/tiger/tgrshp2010/TGRSHP10AA.pdf
My idea is to use the Decorator pattern to have a base Feature class with the fields common to all the data types, then extend it via the decorator pattern for the individual feature types (States, Counties, Congressional Districts, etc). However, I plan to use Google App Engine for hosting, so I have to do this via either JDO or JPA. I would much prefer JPA.
Can I map a decorated object? My idea is that the base feature class would be annotated with @Entity, then the extensions would contain the mapped fields specific to the decorated object. Since the GAE datastore is NOT an RDBMS, I'm thinking I can get away with it.
If you use the Decorator pattern, it means that you use the composition. So what you can do is just mark the class you want to decorate as Embeddable and in your decorator, mark your decorated class as Embedded.
If you prefer to use the inheritance, your base class is not an entity since is just something you want to inherit and not store itself is the DB. To create a base classe which will be inherited from other real entities, there is an annotation for that : @MappedSuperclass
According the GAE docs, both are supported.
Hope it helps!
精彩评论