Hello,
I have one problem with the Any annotation. I have more than one properties in my mapping that depends on the same column/property (in this case TYPE_SETTING).
@Any(metaColumn = @Column(name="TYPE_SETTING",unique=false,updatable=false,insertable=false)) @AnyMetaDef(idType = "int", metaType = "string", metaValues = { @MetaValue(targetEntity = eu.sanco.rasff.model.setting.Company.class, value = TypeSettingEnum.COMPANY_STRING) , @MetaValue(targetEntity = eu.sanco.rasff.model.setting.Laboratory.class, value = TypeSettingEnum.LABORATORY_STRING) ) } ) @JoinColumn(name="CURRENT_SETTING",nullable=false,updatable=true,insertable=true) @Cascade(value = { CascadeType.ALL }) private AbstractSetting current;
@Column(name= "TYPE_SETTING", columnDefinition="INTEGER", nullable = false,updatable=false,insertable=false,unique=false) @Type( type = "eu.sanco.rasff.model.enums.hibernate.TypeSettingEnumUserType" ) private TypeSettingEnum typeSetting;
@Any(metaColumn = @Column(name="TYPE_SETTING",unique=false,updatable=false,insertable=false)) @AnyMetaDef(idType = "int", metaType = "string", metaValues = { @MetaValue(targetEntity = eu.sanco.rasff.model.version.setting.CompanyHistory.class, value = TypeSettingEnum.COMPANY_STRING) , @MetaValue(targetEntity = eu.sanco.rasff.model.version.setting.LaboratoryHistory.class, value = TypeSettingEnum.LABORATORY_STRING)) } ) @JoinColumn(name="PREVIOUS",updatable=true,insertable=true,nullable=true) private IHistoricable previous;
The problem is that I have 2 properties that depending the value of TYPE_SETTING they will be mapped to the result of the AnyMetaDef. I know one solution, but it is not very elegant: to create other column TYPE_SETTING_2 and refer to it.
Please let me know with any update.
Thanks
|