Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for composite Id's #158

Open
angstream555 opened this issue Aug 1, 2019 · 12 comments
Open

Add support for composite Id's #158

angstream555 opened this issue Aug 1, 2019 · 12 comments
Labels
type: enhancement A general enhancement

Comments

@angstream555
Copy link

No way to specify composite id for usage ReactiveCrudRepository

@mp911de mp911de added the type: enhancement A general enhancement label Aug 1, 2019
@mp911de mp911de changed the title No way to specify composite id Add support for composite Id's Aug 1, 2019
@mp911de
Copy link
Member

mp911de commented Aug 1, 2019

We depend on upstream feature availability in Spring Data Relational for composite Id's, see DATAJDBC-352.

@mp911de mp911de added this to the General Backlog milestone Sep 2, 2019
@peterjurkovic
Copy link

any idea when it will be done?

@mp911de
Copy link
Member

mp911de commented Dec 20, 2019

No, we don’t have this feature scheduled yet as we’re busy with other tasks. A pre-requisite is the composite I’d support in Spring Data Relational as the R2DBC module depends on a shared library.

@pwittchen
Copy link

pwittchen commented Apr 7, 2021

Can you suggest any workaround for this until it's done?

edit: I just skipped these annotations, used one element of the composite primary key as a "key" for Repository and used custom query with @Query annotation. Nevertheless, it would be nice to have that feature to make Repository definition right without workarounds.

edit 2: I handled composite key with Tuple2 object. This is kind of workaround, which allows me to reflect schema of the table with composite primary key in the java repository interface and entity class.

@porfirioribeiro
Copy link

@pwittchen do you mind to explain how did you did it with Tuple2?

@pwittchen
Copy link

pwittchen commented Apr 23, 2021

@porfirioribeiro

Something like this:

@Repository
public interface UserRepository extends R2dbcRepository<User, Tuple2<BigDecimal, String> {
  //...
}

I know, this is kind of workaround and won't work with Repository methods provided out of the box like findById(Id) etc. and you need to write custom methods with custom queries anyway, but I keep it for code documentation purposes to avoid providing any (non-composite) key, which is not real database key just to satisfy interface signature and introduce inconsistency between java code in the repository and database schema.

@RodRich1991
Copy link

this is still forgotten =/

@palaknagda
Copy link

@pwittchen Can you please give a reference to your code?

@pwittchen
Copy link

pwittchen commented Apr 7, 2022

@palaknagda Code related to my comment is proprietary and is not open-source. You can see a general idea in my code snippet in the earlier comment. Nevertheless, it does not solve this problem and query inside @Query annotation should work regardless of this change.

@tiagorg-cit
Copy link

Any updates???

@mp911de
Copy link
Member

mp911de commented Apr 28, 2022

Still depends on spring-projects/spring-data-relational#574. A well-crafted pull request along with a decent design can always speed things up.

@paulushcgcj
Copy link

More than 3 years later, no updates so far?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

9 participants