Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving "DiscriminatorColumn" value when querying an object

 
Om Tejas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My class hierarchy looks like this.


This is very simple example for ClassPerHierarchy inheritance and I have set the DiscriminatorColumn and DiscriminatorValue. While doing the query, I also want to retrieve the value in discriminator column. But the value does not come straightforward. I tried by declaring a field "vehicleModel" in Vehicle class but this throws out "Duplicate column" exception.

Any idea how this can be done ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I also want to retrieve the value in discriminator column

Why? Its not a property of your object that should have any meaning beyond defining the type of object. What do you want to do with it?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try making the mapping @Column insertable/updateable=false.

Otherwise, since you know the value for an class without selecting it, you can just define a getDiscriminator method that returns it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic