File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Problem in Extending a POJO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem in Extending a POJO" Watch "Problem in Extending a POJO" New topic

Problem in Extending a POJO

Cheenath Ajay
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
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.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Could you post your mappings and the exception message?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Salary is-a User?

There is no emoticon for what I am feeling!
Cheenath Ajay
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
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 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,,

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Problem in Extending a POJO
It's not a secret anymore!