Dave Tolls wrote:Personally, I would provide a separate query to access the List<C> and try and get the devs to avoid using the List on B...indeed I'd remove the List from B if that was a possibility.
For clarity I am going to call what I was calling "c" before...."fieldB"
Hey David,
Ok suppose we did get rid of the List<B> completely from A. Would that work smoothly then? What annotation would you use? I'm thinking @SecondaryTable seems the most helpful. Also would we still have that @OneToMany mapping for List<fieldB> in A? I mean technically that is their relationship still.
My only concern is B had a primary key pair including A's primary key and fieldB. So A's primary key is also B's foreign key.
When entity A is saved, will hibernate be smart enough to know that List<fieldB> is mapped to Table B (which we will tell it by annotation @SecondaryTable I assume) AND that the primary key to Table B is say fieldA (which is on A) and fieldB? Do you understand my concern? Let me write another snippet describing this
Before:
And of course after we just want a List<fieldB> in A and completely forget about B together but still being able to read/write the values from List<fieldB>
We just need to make sure Hibernate KNOWS that the primary key for Table B is fieldA and fieldB. Before we explicitly did this in entity B, not sure if we can do this anymore.