• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate: Select only from "Parent"-table in union-subclass  RSS feed

Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi fellow saloonists!

I have class A and Class B extends A, both are mapped using union-subclass in Hibernate. I'm using a <generator class="increment" /> defined in A.

My program uses a "from A a where a.name =:var1" query, which should return one or zero rows.
If zero rows are returned then save A.
If one row is returned, then create a new object B with the properties of A (e.g. name), set another property in B (e.g. the ID of A) and save it.

The above works fine. Then I run the process again, but this time my query returns 2 rows, as the variable fits objects both in table A and table B.

How do I force Hibernate not the search the table containing the B-objects when I'm selecting A-objects?


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!