Skip to main content

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

Hello,

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 s.id = 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">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
		
		<class>net.uniopt.domain.config.Scenario</class>
		<class>net.uniopt.domain.sys.Language</class>
		<class>net.uniopt.domain.usrmngmt.LoginUser</class>

    <properties>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.url"
value="jdbc:mysql://smithers:3306/ot_diermeier_324"/>
      <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" />
    </properties>

  </persistence-unit>


Any hint is appreciated.

Kind Regards, Michael


Back to the top