Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to prevent EL from creating Reference ReadAllQuery
How to prevent EL from creating Reference ReadAllQuery [message #892659] Fri, 29 June 2012 04:29 Go to next message
warz warz is currently offline warz warzFriend
Messages: 6
Registered: May 2012
Junior Member
I have a very frequent problem that involves entities and query relationships being referenced when one object is queried. From the stack trace below, the only query i agree with is the first one where i am directly querying for the
UserAccount
object. I have set up a few weaving options to prevent this with an example of persitence.xml file:

            <property name="eclipselink.ddl-generation" value="none"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
            <property name="eclipselink.weaving" value="static"/>
            <property name="eclipselink.logging.level" value="FINEST"/>     
			<property name="eclipselink.weaving.internal" value="false"/> 
			<property name="eclipselink.weaving.fetchgroups" value="false"/>
			<property name="eclipselink.weaving.changetracking" value="false"/>  


All of my
@OneToMany, @ManyToMany and @OneToOne
relationships have the keyword
fetch = FetchType.Lazy
but there might be a
JoinFetch left-join query hint
conflict in my query below:
		EntityManager entityManager = factory.createEntityManager();
        /*Create a data structure to hold a list of users in our database*/
		
		UserAccount tempUser = null;
		
			
			try {
			    UserAccount user = (UserAccount)entityManager.createQuery("SELECT user FROM UserAccount user where user.username = :username")
			        .setParameter ("username", username).setHint("eclipselink.left-join-fetch", "u.person.address").setHint("eclipselink.left-join-fetch", "u.person.school.address")
			        .getSingleResult();
			    return user;
			} catch (EmptyResultDataAccessException e) {
			    //There is no user with this username - do something
				return null;
			} catch (NonUniqueResultException e) {
			    //There is more than one user with this username - do something
			}	
			
		entityManager.close();


How can i prevent this so that when i ask for a single object, i only get that object and No injenction and autowiring does not happen (I am using Spring Roo which should not generate any SQL)

Stack Trace

[EL Finest]: connection: 2012-06-28 23:03:07.942--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:07.942--ServerSession(1021946387)--Connection(678613912)--Thread(Thread[main,5,main])--SELECT userID, EMAIL, ISLOCKED, LOGINATTEMPTS, passwordHash, PASSWORDRESETDATE, passwordSalt, USERNAME, version, PERSON_personID FROM USERACCOUNT WHERE (USERNAME = ?)
	bind => [admin]
[EL Finest]: connection: 2012-06-28 23:03:07.95--ServerSession(1021946387)--Connection(1395706699)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
2012-06-28 23:03:07,953 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.UserAccount': PersistenceElement for transient javax.persistence.EntityManager org.bixin.dugsi.domain.UserAccount.entityManager
2012-06-28 23:03:07,954 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
2012-06-28 23:03:07,954 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.UserAccount': AutowiredFieldElement for private java.lang.Boolean org.bixin.dugsi.domain.UserAccount.isLocked
2012-06-28 23:03:07,954 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,954 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,954 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,955 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,955 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,955 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,955 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,956 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,956 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,956 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,956 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,957 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,957 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,957 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,957 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,957 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,957 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.UserAccount': AutowiredFieldElement for private int org.bixin.dugsi.domain.UserAccount.loginAttempts
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,958 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,959 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,959 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,962 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,963 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,963 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,963 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,963 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,963 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,963 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,964 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
[EL Finest]: query: 2012-06-28 23:03:07.965--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="person" referenceClass=Person )
[EL Finest]: connection: 2012-06-28 23:03:07.966--ServerSession(1021946387)--Connection(558455736)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:07.966--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:07.967--ServerSession(1021946387)--Connection(1462017562)--Thread(Thread[main,5,main])--SELECT personID, TYPE, DATEADDED, FIRSTNAME, LASTNAME, MIDDLENAME, ACTIVE, BIRTHDAY, EMAILADDRESS, ETHNICITY, GENDER, HISPANIC, IMAGEPATH, MARITAL, NATIVELANGUAGE, PRIMARYTELEPHONE, RELIGIOUSAFFILIATION, SECONDARYTELEPHONE, version, addressID, schoolID, MAJOR, studentId FROM PERSON WHERE (personID = ?)
	bind => [10000]
[EL Finest]: connection: 2012-06-28 23:03:07.97--ServerSession(1021946387)--Connection(558455736)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
2012-06-28 23:03:07,970 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.Student': PersistenceElement for transient javax.persistence.EntityManager org.bixin.dugsi.domain.Person.entityManager
2012-06-28 23:03:07,971 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
[EL Finest]: query: 2012-06-28 23:03:07.972--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="address" referenceClass=Address )
[EL Finest]: connection: 2012-06-28 23:03:07.972--ServerSession(1021946387)--Connection(293359801)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:07.972--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:07.973--ServerSession(1021946387)--Connection(2023205542)--Thread(Thread[main,5,main])--SELECT addressID, CITY, COUNTRY, STATE_US, STREETADDRESS, STREETADDRESS2, version, ZIPCODE FROM ADDRESS WHERE (addressID = ?)
	bind => [1]
[EL Finest]: connection: 2012-06-28 23:03:07.975--ServerSession(1021946387)--Connection(293359801)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
2012-06-28 23:03:07,975 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.Address': PersistenceElement for transient javax.persistence.EntityManager org.bixin.dugsi.domain.Address.entityManager
2012-06-28 23:03:07,976 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
[EL Finest]: query: 2012-06-28 23:03:07.978--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="school" referenceClass=School )
[EL Finest]: connection: 2012-06-28 23:03:07.978--ServerSession(1021946387)--Connection(2038638222)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:07.978--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:07.979--ServerSession(1021946387)--Connection(291009269)--Thread(Thread[main,5,main])--SELECT schoolID, ACTIVE, ADMISSIONSEMAILADDRESS, ADMISSIONSPHONE, CODE, description, HELPGENERALEMAILADDRESS, NAME, PRIMARYPHONE, version, addressID FROM SCHOOL WHERE (schoolID = ?)
	bind => [1]
[EL Finest]: connection: 2012-06-28 23:03:07.982--ServerSession(1021946387)--Connection(2038638222)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
2012-06-28 23:03:07,983 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.School': PersistenceElement for transient javax.persistence.EntityManager org.bixin.dugsi.domain.School.entityManager
2012-06-28 23:03:07,983 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
[EL Finest]: query: 2012-06-28 23:03:07.984--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="address" referenceClass=Address )
[EL Finest]: connection: 2012-06-28 23:03:07.984--ServerSession(1021946387)--Connection(1619572824)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:07.984--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:07.985--ServerSession(1021946387)--Connection(805227243)--Thread(Thread[main,5,main])--SELECT addressID, CITY, COUNTRY, STATE_US, STREETADDRESS, STREETADDRESS2, version, ZIPCODE FROM ADDRESS WHERE (addressID = ?)
	bind => [3]
[EL Finest]: connection: 2012-06-28 23:03:07.986--ServerSession(1021946387)--Connection(1619572824)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
2012-06-28 23:03:07,986 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.Address': PersistenceElement for transient javax.persistence.EntityManager org.bixin.dugsi.domain.Address.entityManager
2012-06-28 23:03:07,987 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
2012-06-28 23:03:07,989 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.UserAccount': PersistenceElement for transient javax.persistence.EntityManager org.bixin.dugsi.domain.UserAccount.entityManager
2012-06-28 23:03:07,990 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
2012-06-28 23:03:07,990 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.UserAccount': AutowiredFieldElement for private java.lang.Boolean org.bixin.dugsi.domain.UserAccount.isLocked
2012-06-28 23:03:07,990 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,990 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,990 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,990 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,991 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'org.bixin.dugsi.domain.UserAccount': AutowiredFieldElement for private int org.bixin.dugsi.domain.UserAccount.loginAttempts
2012-06-28 23:03:07,992 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,993 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initializing new StandardEnvironment
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
2012-06-28 23:03:07,994 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
[EL Finest]: transaction: 2012-06-28 23:03:07.995--UnitOfWork(1411077618)--Thread(Thread[main,5,main])--[EL Finest]: query: 2012-06-28 23:03:08.005--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadAllQuery(name="registrations" referenceClass=Registration )
[EL Finest]: connection: 2012-06-28 23:03:08.006--ServerSession(1021946387)--Connection(939536212)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:08.006--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:08.007--ServerSession(1021946387)--Connection(337858693)--Thread(Thread[main,5,main])--SELECT registrationId, SEMESTERTAKEN, version, YEAR, semesterCourseId, personID FROM REGISTRATION WHERE (personID = ?)
	bind => [10000]
[EL Finest]: connection: 2012-06-28 23:03:08.008--ServerSession(1021946387)--Connection(939536212)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
[EL Finest]: query: 2012-06-28 23:03:08.009--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadAllQuery(name="schools" referenceClass=ApplicantSchool )
[EL Finest]: connection: 2012-06-28 23:03:08.011--ServerSession(1021946387)--Connection(1101985688)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:08.011--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:08.012--ServerSession(1021946387)--Connection(1174486488)--Thread(Thread[main,5,main])--SELECT applicantSchoolID, CREDITSCOMPLETED, FROMMONTH, FROMYEAR, GPA, NAME, SCHOOLTYPE, TOMONTH, TOYEAR, version, APPLICANT_personID FROM APPLICANTSCHOOL WHERE (APPLICANT_personID = ?)
	bind => [10000]
[EL Finest]: connection: 2012-06-28 23:03:08.013--ServerSession(1021946387)--Connection(1101985688)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
[EL Finest]: query: 2012-06-28 23:03:08.02--ServerSession(1021946387)--Thread(Thread[main,5,main])--Execute query ReadAllQuery(name="persons" referenceClass=Person )
[EL Finest]: connection: 2012-06-28 23:03:08.021--ServerSession(1021946387)--Connection(304483725)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: connection: 2012-06-28 23:03:08.021--ServerSession(1021946387)--Thread(Thread[main,5,main])--reconnecting to external connection pool
[EL Fine]: sql: 2012-06-28 23:03:08.022--ServerSession(1021946387)--Connection(4435274)--Thread(Thread[main,5,main])--SELECT personID, TYPE, DATEADDED, FIRSTNAME, LASTNAME, MIDDLENAME, ACTIVE, BIRTHDAY, EMAILADDRESS, ETHNICITY, GENDER, HISPANIC, IMAGEPATH, MARITAL, NATIVELANGUAGE, PRIMARYTELEPHONE, RELIGIOUSAFFILIATION, SECONDARYTELEPHONE, version, addressID, schoolID, MAJOR, studentId FROM PERSON WHERE (addressID = ?)
	bind => [1]
[EL Finest]: connection: 2012-06-28 23:03:08.023--ServerSession(1021946387)--Connection(304483725)--Thread(Thread[main,5,main])--Connection released to connection pool [read].

Re: How to prevent EL from creating Reference ReadAllQuery [message #892660 is a reply to message #892659] Fri, 29 June 2012 04:30 Go to previous messageGo to next message
warz warz is currently offline warz warzFriend
Messages: 6
Registered: May 2012
Junior Member
No Message Body
Re: How to prevent EL from creating Reference ReadAllQuery [message #892751 is a reply to message #892659] Fri, 29 June 2012 13:29 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The first query is getting a cache hit and returning the UserAccount object as it is in the cache. But because you have fetch join specified, it must trigger those relationships before returning it, which is causing the extra queries as the lazy relationships were set by the query that originally read in/built the UserAccount object.

You can force the query to the database by additionally setting the refresh query hint "eclipselink.refresh" with a value of true. This will cause the object to be rebuilt from the database results.

Best Regards,
Chris
Re: How to prevent EL from creating Reference ReadAllQuery [message #892814 is a reply to message #892751] Fri, 29 June 2012 20:24 Go to previous messageGo to next message
warz warz is currently offline warz warzFriend
Messages: 6
Registered: May 2012
Junior Member
Chris,

I just added that query hint making my code look like this

			    UserAccount user = (UserAccount)entityManager.createQuery("SELECT user FROM UserAccount user where user.username = :username")
			        .setParameter ("username", username).setHint("eclipselink.refresh", "true").setHint("eclipselink.left-join-fetch", "u.person.address")
			        .setHint("eclipselink.left-join-fetch", "u.person.school.address")
			        .getSingleResult();


Yet i still get ObjectReadQueries and Injection of metadata with references to other related entities? Could it be that autowire = true in the @Configurable notation?
Re: How to prevent EL from creating Reference ReadAllQuery [message #892817 is a reply to message #892659] Fri, 29 June 2012 20:59 Go to previous messageGo to next message
warz warz is currently offline warz warzFriend
Messages: 6
Registered: May 2012
Junior Member
Also if i didnt include in my stack trace, this is probably causing the problem as weaving is not taking place defaulting to eager fetching and ignoring my Lazy relationship call

[Thread(Thread[main,5,main])--Reverting the lazy setting on the OneToOne or ManyToOne attribute [school] for the entity class [class org.bixin.dugsi.domain.Person] since weaving was not enabled or did not occur.

Re: How to prevent EL from creating Reference ReadAllQuery [message #893328 is a reply to message #892817] Tue, 03 July 2012 14:46 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Yes, weaving is required for OneToOne relationships to be lazy. I would try again removing all the eclipselink.weaving.* settings, and run the static weaver on your jar before deploying (and keeping the eclipselink.weaving = static property) and see if this helps in conjunction with refreshing the entity as mentioned in my first post.

Best Regards,
Chris
Previous Topic:not retrieving entity when an attribute of it has value 0.0
Next Topic:Informix table creation error
Goto Forum:
  


Current Time: Sat Apr 20 01:08:24 GMT 2024

Powered by FUDForum. Page generated in 0.03260 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top