design - Hibernate - Don't map some fields from super class -


i using hibernate 4.1 , annotations mapping java db.

i have super class attributes mapped using @mappedsuperclass.

this class has many subclasses of attributes not valid subclasses, hence don't want map them database subclasses.

is there way of achieving this?

also, not sure if correct design or not subset of properties of super class applicable subclass ? open change design if 1 give me valid reason.

that said, still interested in knowing whether original problem solvable using jpa/hibernate.

thanks in advance.

i'm not sure whether or not there way want hibernate, sounds real problem design/class structure. in short, fields don't apply of subclasses shouldn't reside in superclass.

you should either move fields subclasses in apply, or create new intermediate class fields , extend instead. example, consider class structure:

class animal {   float weight;   color[] haircolors; } class dog extends animal {} class fish extends animal {} 

haircolors doesn't apply fish. should move dog or create new intermediate class, e.g. mammal:

class animal {   float weight; } class mammal extends animal {   color[] haircolors; } class dog extends mammal {} class fish extends animal {} 

Comments