Win a copy of Svelte and Sapper in Action this week in the JavaScript 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem in Extending a POJO

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I am using two POJOs in my application, One is User and another is Salary.
And i am extending User in my Salary POJO, But one i try to query something in User POJO Hibernate throwing some errors like Property of User POJO is not there in Salary POJO.

Like userName is not a property of Salary POJO.

Why this happening, Is there any solution for this?

Thanks in Advance.

Cheenth.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post your mappings and the exception message?
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salary is-a User?
 
Cheenath Ajay
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try to explain more on my problem,

I need to represnt my child tables as child classes. Here salary table is a child table of users table. Thats the reason why i am extending UserPOJO in my SalaryPOJO.

It is working fine with all other CRUD operations expect using a select with conditions.

I would like to create an API for an application where all child table mapping POJOs will be extending its parent table POJO.

Last time i tried with <join-subclass>
but while inserting a record in child class(using session.save(Object)) its trying to insert corresponding records in its parent table.


Say while inserting a record in salary its trying to insert a corresponding record in its parent(Users) and since key for that User record is already existing its showing dupicate entry exception.

Can i avoid insertion of parent record while inserting a child record, if there is a record already existing the same primary key??

Please help me to solve my issue.

Thanking you all,,

Cheenath.
 
Do Re Mi Fa So La Tiny Ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic