1

As outlined in the heading, I am seeing problems whereby I am attempting to map two different classes to the same table. Each class has a different primary key; one has a primary key equal to that on the physical table, the other uses a composite of 2 different fields.

The reason I am attempting this is because we recently switched the primary key on the table, and we would like to be able to support the legacy classes and the new classes.

Can some confirm if what I am doing is not possible?

Thanks

1 Answer 1

1

When you declare same table, with two different classes, it will work but you should give a serious thought for that idea as it could create many problems in the future.

Since, the primary keys are changed in the table, inserting data to the table using the old bean is not going to work any more. so, essentially there is not much use with your old class.

What I would suggest is to change your old class's id mapping to reflect the new changes you have made in the table. The difficult part is to manage the change in the database, since you have do that, the corresponding Java change must be simpler, give it a try.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.