Hibernate version: 3.6.0 GA
Mapping documents: 3.3.0 GA
Name and version of the database you are using: MS SQL Server 2005 Express.
Hi all...!
And now, for something completly differente, I'm trying to map a composite key in a very special situation.
I have this previous conditions:
- Legacy database, that is forbidden to change.
- Domain model with POJOs that also cannot be modified.
And this is the problem that drives me crazy... First I have this class:
@Entity
public ExampleClass {
@Id
private Long id;
@ManyToOne
private A a;
@ManyToOne
private B b;
// lots of funny fields
}
An this is the table:
EXAMPLE_CLASS
--------------------
a_id (PK)
b_id (PK)
... (those funny columns)
As you can see, the table hasn't any id column and instead has a composite key using a and b primary keys.
Yeah, I will I could add the id column, but since I cannot modify the database model neither the domain model, it remains impossible.
What I'm looking for is a way - maybe tricky a one or even a dirty, antipattern or foolish one - for mapping or building that relation between the class and the table.
What I need - desperately - is a way that works.
Well, I have insulted you enough with my poor English. Thank you all, answers will be regarded with beer, if you are near Madrid (Spain). If not, I will send you an electronic pint.
Bye!
|