Hi all, I have a DB mapped to Java objects using Hibernate. Some of the objects are inherited from the others, and the mapping is using joined strategy: I have an Attribute class mapped to attributes table, and it is extended by AttributeColor class mapped (joined strategy) to attributes_colors table. This means that if I have 5 Attribute instances and 2 AttributeColor instances, the attributes table will contain 7 rows. My question is how can I query only Attribute instances and not AttributeColor instances? Meaning I want to query a total of 5 objects. Using a query "from Attribute" will return all the seven rows. Solutions on line suggest ways to query all the rows (total of 7), but all as Attribute instances. This is not exactly what I want. I need to omit all the rows which are joined to child tables.
One option is to use a discriminator column, but one of the reasons I am using joined strategy is to avoid this. Is there another option to create such query?
Thanks, Guy
|