0

I want to write one hbm file.

My class hierarchy is

BaseClassOne{
private long id;
...getters and setters....
}

ClassA extends BaseClassOne{
other private members;
...getters and setters....
}

classB extends BaseClassOne{
other private members;
...getters and setters....
}

now,

I am writing another classsay ClassMain which will have object type of ClassA OR classB depending on some criteria(say column type in ClassMain)

in my model class i have written

..other private members ....

private BaseClassOne objectAtRuntime;


...getters setters.....

Now, Please tell me in hbm files how to implement this...???

or tell me other alternatives to implement the same.

JOHND
  • 2,597
  • 6
  • 27
  • 35

1 Answers1

0

this is what <any> mapping is for. See here for a blogpost describing how to map it in xml. Despite it being written for NHibernate it should be the same for hibernate

Firo
  • 30,626
  • 4
  • 55
  • 94