@JoinFormula y @OneToMany definición-documentación deficiente
Tengo dos preguntas sobre las anotaciones @JoinFormula y @OneToMany:
¿Cómo puedo limitar el número de resultados con
@JoinFormula
y@OneToMany
anotaciones?-
¿Cómo puedo definir que
id
en la expresiónauthor = id
se refiere aAuthor.id
?Author { @Id private Long id; @OneToMany @JoinFormula(value = "SELECT a FROM Article a WHERE author = id AND schedule < CURRENT_TIMESTAMP()") // limit = 15 private List<Article> pastArticles; }
Así, sigo teniendo los pastArticles vacíos, incluso cuando elimino la parte schedule <
de la cláusula.
Gracias!
23
Author: DataNucleus, 2012-03-31
2 answers
Respuesta 1:
@Size(max=10)
private List<Comment> commentList;
Respuesta 2: (solo ejemplo como ese)
public class A{
@Id
@GeneratedValue
private Integer id;
private String uuid;
...
}
Otra clase
public class B{
@Id
@GeneratedValue
private Integer id;
private String uuidOfA;
@ManyToOne
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(formula=@JoinFormula(value="(SELECT a.id FROM A a WHERE a.uuid = uuid)", referencedColumnName="id")),
@JoinColumnOrFormula(column = @JoinColumn("uuidOfA", referencedColumnName="uuid"))
})
private A a;
}
10
Author: Jubin Patel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-14 05:14:20
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-14 05:14:20
Sería mejor usar la anotación @Where
para limitar los resultados
1
Author: Dr Gorb,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-09-02 14:48:41
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-09-02 14:48:41