P
P
piatachki2017-08-01 08:28:17
SQL
piatachki, 2017-08-01 08:28:17

How to use Spring CrudRepository with composite key?

The repository is auto-implemented from the view interface

@Repository
CrudRepository<Obj, ID>

parameterized by the actual object and key type. If I really don't want to introduce a surrogate long-key with auto-increment in the table, how can I make the repository work with a composite key of two Integer and String fields?
Is it possible to do something like your own key class
class Id {
Integer parent_id;
String name;
}

Are there any solution templates? The task is quite typical, but, apparently, because of my English, Google refuses to cooperate with me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kuznetsov, 2017-08-01
@piatachki

Do you need this? https://stackoverflow.com/questions/35054372/how-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question