Setting up play 2.0 tagging using only 2 model objects?
-
30-05-2021 - |
Pregunta
Ok, so I want to implement tags in my play 2.0 app,
Basically what I am thinking to do right now, is to use 3 tables, Questions, Tags and Question_Tags.
Should I just use different model objects for each?
Or is there some way I can set it up so that I only use Items, and Tags models, and the TagItems gets generated automatically by play?
For example, could I instead to something along the lines of:
@Id
public String tag;
public ArrayList<Question> questions;
and let ebean handle the mapping? seems like this would be a better abstraction...
I am using Play 2.0, EBean with a MySql database, jdbc driver.
Solución
Ebeans uses JPA annotations, so you can use a standard JPA @ManyToMany annotation between Questions and Tags and Ebeans will manage the tables required behind the scenes.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow