I have a database which is using composite keys. Is it possible to utilize spring-data-jdbc? I tried the milestone version 1.1M2 where I mapped my entity in the following way:
class History {
@ID
@Embedded
private CompositeHistoryID id;
}
Then in my repository class, I added
HistoryRepository extends Repository<History,CompositeHistoryID >{
History findByhId(CompositeHistoryID id)
}
I traced the SQL, and it did not work. The embedded part worked, but the where clause was not correct. It was using a single parameter holder instead of having the regular composite key structure where element1=subkey1 and element2=subkey2 and so on...
I have two questions. Is there any way to make the Composite ID work?
The second question is, let's suppose that I use a custom @Query
on top of the findByID
will the SAVE method work after that if? What is there is no ID at all, what if I just pick a random column and say you will be my ID?