M
M
milky_cookie2011-12-27 00:29:47
Java
milky_cookie, 2011-12-27 00:29:47

Class mapping?

Good night to all Khabrovites!
I resisted for a long time, but still I need your advice - I have a task that is not standard for me, which I cannot cope with. I need to link 4 classes with my own annotations, respectively 4 types of links (“1:1”, “1:*”, “*:*”, “*:1”). That is, in the final result, on demand, the program must determine all the links for any class. The Java language, ORM is impossible - only its annotations. I will be eternally grateful to everyone who responds

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serso, 2011-12-27
@milky_cookie

As far as I understand the problem, you only need one annotation, like:

public @interface ClassReference {
  Class<?>[] values();
}

Then you can associate one class with N classes:
1. If 1 class is specified in values ​​and this class has a “reverse” annotation on this class - 1 to 1
2. If N classes are specified in values ​​and they all have a “reverse” annotation for this class - 1 to N
3. If N classes are indicated in values ​​and they, in turn, have links to other classes - N to M
PS If this is not a solution, then clarify the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question