Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Retrieving "DiscriminatorColumn" value when querying an object  RSS feed

 
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 ?
 
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?
 
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
Boost this thread!