@Embeddable public static class FooEmbeddable { @AnyMetaDef(idType = "integer", metaType = "string", metaValues = { @MetaValue(value = "1", targetEntity = Bar1.class), @MetaValue(value = "2", targetEntity = Bar2.class) }) @Any(metaColumn = @Column(name = "bar_type")) @JoinColumn(name = "bar_id") private BarInt bar; public BarInt getBar() { return bar; } public void setBar(BarInt bar) { this.bar = bar; } }
@ManyToAny( metaColumn = @Column( name = "property_type" ) ) @AnyMetaDef( idType = "integer", metaType = "string", metaValues = { @MetaValue( value = "S", targetEntity = StringProperty.class ), @MetaValue( value = "I", targetEntity = IntegerProperty.class ) } ) @Cascade( { org.hibernate.annotations.CascadeType.ALL } ) @JoinTable( name = "obj_properties", joinColumns = @JoinColumn( name = "obj_id" ), inverseJoinColumns = @JoinColumn( name = "property_id" ) ) public List<Property> getGeneralProperties() { return generalProperties; }
@Any( metaColumn = @Column( name = "property_type" ) ) @Cascade( value = { CascadeType.ALL } ) @AnyMetaDef( idType = "integer", metaType = "string", metaValues = { @MetaValue( value = "S", targetEntity = StringProperty.class ), @MetaValue( value = "I", targetEntity = IntegerProperty.class ) } ) @JoinColumn( name = "property_id" ) public Property getSomeProperty() { return someProperty; }
@Any( metaColumn = @Column( name = "property_type" ), fetch = FetchType.LAZY ) @Cascade( value = { CascadeType.ALL } ) @AnyMetaDef( idType = "integer", metaType = "string", metaValues = { @MetaValue( value = "S", targetEntity = StringProperty.class ), @MetaValue( value = "I", targetEntity = IntegerProperty.class ) } ) @JoinColumn( name = "property_id" ) public Property getSomeProperty() { return someProperty; }
@ManyToAny( metaColumn = @Column( name = "property_type" ) ) @AnyMetaDef( idType = "integer", metaType = "string", metaValues = { @MetaValue( value = "S", targetEntity = StringProperty.class ), @MetaValue( value = "I", targetEntity = IntegerProperty.class ) } ) @Cascade( org.hibernate.annotations.CascadeType.ALL ) @JoinTable( name = "map_properties", joinColumns = @JoinColumn( name = "map_id" ), inverseJoinColumns = @JoinColumn( name = "property_id" ) ) @MapKeyColumn( name = "map_key", nullable = false ) //keep for legacy test public Map<String, Property> getProperties() { return properties; }
@Any(metaColumn = @Column(name = "property_type")) @AnyMetaDef(idType = "long", metaType = "string", metaValues = { @MetaValue(targetEntity = example.Tractor.class, value = "tractor"), @MetaValue(targetEntity = example.Smartphone.class, value = "smartphone") }) @JoinColumn(name = "property_id") @ToOne public Device getMyStuff() { return myStuff; } }