How to make hibernate issue one "Insert" sql statement ? (and not some unnecessary Selects) ?
In a simple case where I have Person object that has many Emails, and I want to add an email address to some person I do the following (taken from Hibernate example):
session.beginTransaction(); Person aPerson = (Person) session.load(Person.class, personId); aPerson.getEmailAddresses().add(emailAddress); session.getTransaction().commit();
checking the logs, hibernate execute THREE sql stmt for that:
Hibernate: select person0_.PERSON_ID as PERSON1_2_0_, person0_.age as age2_0_, ...
Hibernate: select emailaddre0_.PERSON_ID as PERSON1_0_, emailaddre0_.EMAIL_ADDR as EMAIL2_0_ from PERSON_EMAIL_ADDR .....
Hibernate: insert into PERSON_EMAIL_ADDR (PERSON_ID, EMAIL_ADDR) values (?, ?)
why THREE ? why not just the "INSERT" ? how do I execute just one simple INSERT statement with Hibernate ? (without the TWO selects)
|