Hi
I have entity with a @CollectionOfElements-field.
When I run a query (using a regular query.getResultList()), hibernate first does a SELECT on both tables, then DELETEs all the rows in the JoinTable and then INSERTS the same rows!
What's going on here? Any ideas....?
thanks!
Entity:
Code:
@Entity
@NamedQuery(
name="findUserByEmail",
query="FROM PortalUser p WHERE p.email = :email"
)
@SequenceGenerator(name = "KPANV_SEQUENCE", sequenceName = "KP_ANVANDARID_SQ", allocationSize = 1)
@Table(name = "LGAB_KPANVANDARE")
public class PortalUser {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "KPANV_SEQUENCE")
@Column(name = "ANVANDARID")
private long id;
...
@CollectionOfElements
@JoinTable(name = "LGAB_KPBEVAKADSTATUS", joinColumns = { @JoinColumn(name = "ANVANDARID") })
private Set<SubscribedStatus> statuses;
Generated SQL:Code:
16:34:12,240 INFO [STDOUT] Hibernate:
select
portaluser0_.ANVANDARID as ANVANDARID95_,
portaluser0_.EMAIL as EMAIL95_,
portaluser0_.REGDATBEVAKN as REGDATBE3_95_,
portaluser0_.SMS as SMS95_,
portaluser0_.BEVAKNVIASMSJN as BEVAKNVI5_95_,
portaluser0_.REGDATRPTPRENUM as REGDATRP6_95_
from
LGAB_KPANVANDARE portaluser0_
where
portaluser0_.EMAIL=?
16:34:12,271 INFO [STDOUT] Hibernate:
select
statuses0_.ANVANDARID as ANVANDARID0_,
statuses0_.KPSTATUS as KPSTATUS0_
from
LGAB_KPBEVAKADSTATUS statuses0_
where
statuses0_.ANVANDARID=?
16:34:12,287 INFO [STDOUT] Hibernate:
delete
from
LGAB_KPBEVAKADSTATUS
where
ANVANDARID=?
and KPSTATUS=?
16:34:12,287 INFO [STDOUT] Hibernate:
delete
from
LGAB_KPBEVAKADSTATUS
where
ANVANDARID=?
and KPSTATUS=?
16:34:12,302 INFO [STDOUT] Hibernate:
insert
into
LGAB_KPBEVAKADSTATUS
(ANVANDARID, KPSTATUS)
values
(?, ?)
16:34:12,302 INFO [STDOUT] Hibernate:
insert
into
LGAB_KPBEVAKADSTATUS
(ANVANDARID, KPSTATUS)
values
(?, ?)