SetFirstResult and setMaxResult problem if exist @OneToMany relation [message #1063094] |
Wed, 12 June 2013 05:35  |
Eclipse User |
|
|
|
Hi,
i use EclipseLink 2.4, JPA 2.0 and Spring framework.
I have the following entity:
@Entity
@Table(name="DIPENDENTE")
public class Dipendente implements Serializable {
@Id
@Column(name="C_DIPENDENTE")
private String cDipendente;
@Column(name="NOME")
private String nome;
@Column(name="COGNOME")
private String cognome;
@JoinFetch(JoinFetchType.INNER)
@OneToMany(mappedBy="dipendente", cascade = {CascadeType.PERSIST,CascadeType.MERGE})
private List<Recapito> recapito;
.......
}
@Entity
@Table(name="RECAPITO")
public class Recapito implements Serializable {
@Id
@Column(name="C_RECAPITO")
private String cRecapito;
@Column(name="VIA")
private String via;
@ManyToOne
private Dipendente dipendente
.......
}
In DB I have this data:
DIPENDENTE
C_DIPENDENTE NOME COGNOME
1 x y
2 xx yy
3 xxx yyy
4 xxxx yyyy
5 z p
6 zz pp
7 zzz ppp
8 zzzz pppp
9 k t
10 kk tt
11 kkk ttt
RECAPITO
C_RECAPITO VIA C_DIPENDENTE
1 v 1
2 vv 1
3 vvv 1
4 g 2
5 j 3
6 l 4
7 m 5
8 n 6
9 e 7
10 dd 8
11 ss 9
12 ko 10
13 ft 11
when I execute JPQL query:
SELECT DISTINCT d FROM Dipendente d ORDER BY d.COGNOME, d.NOME, d.C_DIPENDENTE
with
query.setFirstResult(0);
query.setMaxResults(10);
the result is:
C_DIPENDENTE NOME COGNOME C_RECAPITO VIA C_DIPENDENTE_1
1 x y 1 v 1
1 x y 2 vv 1
1 x y 3 vvv 1
2 xx yy 4 g 2
3 xxx yyy 5 j 3
4 xxxx yyyy 6 l 4
5 z p 7 m 5
6 zz pp 8 n 6
7 zzz ppp 9 e 7
8 zzzz pppp 10 dd 8
and the object size in java has size 8 instead of 10
How to solve this problem?
Thanks
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02978 seconds