Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unexpected Queries

Hi Michael,

  Are you running in an application server, or in Java SE?

In EclipseLink LAZY xToOne mappings are implementated using weaving, so depending on your deployment strategy, you may have to do some configuration.

- In you are in a Java EE compliant application server, everything should work automatically
- If you are in Java SE, you should run with a java agent
- If you are in a non Java EE compliant server, you should use static weaving

  Here are some docs about weaving:


Michael Simons wrote:

Assume the following part of our model
Scenario (N:1) LoginUser (N:1) Language
No attribute is marked "FetchType.EAGER" but all are "LAZY".

My test program does the following JPQ:
  Query q = em.createQuery ("select s from Scenario s where = 1");
  Scenario scenario = (Scenario)q.getSingleResult ();

But EL generates the following queries:
  SELECT scenario_id, creation_date, vrsion, nme, ext_id, alt_ex_id, jdo_version, login_user_id
  FROM scenario WHERE (scenario_id = 1);

  SELECT login_user_id, passwd, mail, phone, alias, nme, login, lnguage_id, sales_office_id
  FROM login_user WHERE (login_user_id = 1);

  SELECT lnguage_id, nme, abbreviation FROM lnguage WHERE (lnguage_id = 1);

So for a reason I don't know of, EL descides to load the "owner" (login_user) of the scenario as
well as the "language" (lnguage_id) of that user.

EL behaves the same on other JPQL-Queries, that leads to a problem, because every line is
selected in a single statement. So this leads to a mass of SQL statements.

My persistence.xml:
  <persistence-unit name="otee" transaction-type="RESOURCE_LOCAL">

      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.url"
      <property name="javax.persistence.jdbc.user" value="otcs"/>
      <property name="javax.persistence.jdbc.password" value="otcs"/>
      <property name="eclipselink.persistence-context.flush-mode" value="Commit" />
      <!-- To print SQL statements  -->
      <property name="eclipselink.logging.level" value="FINE" />


Any hint is appreciated.

Kind Regards, Michael
eclipselink-users mailing list

Back to the top