I need to have a table of Registered_Systems with System_id, name, description etc. Now each System can have n number of attributes which I have planned to store in a child table Registered_System_Attributes(System_id,Attribute_name, Attribute_Value ) with a foreign key to Registered_Systems.System_id
As an Attribute must have a System associated, I was planning to make the class RegisteredSystemAttribute as Embeddable and define
@Entity
@Table(name = "Registered_Systems")
public class RegisteredSystem {
...
@ElementCollection
@CollectionTable(name = "Registered_System_Attributes", joinColumns = { @JoinColumn(name = "System_id", referencedColumnName = "System_id") })
private Set<RegisteredSystemAttribute> registeredSystemAttributes;
...
}
If modeled this way, how to return System names based the attribute name & the value supplied?
Any help on this is more than welcome.
I am using
- spring-data-commons-1.6.3.RELEASE.jar
- spring-data-jpa-1.4.3.RELEASE.jar
- (i)hibernate-entitymanager-4.2.14.SP1-redhat-1.jar, (ii) hibernate-jpa-2.0-api-1.0.1.Final-redhat-2.jar offered by JBOSS EAP 6.3