Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] select part of an entity

The issue is the htmlBody is a LAZY Basic, so not fetched on the find().  The
access to it should fetch it.  Is the object detached?  I think the fetch
may have to occur while the EntityManager is active.

This may have been fixed, please try the latest EclipseLink release.  If it
still fails, please log a bug. (include what the find() method does).



Derek Knapp-3 wrote:
> 
> I now get this exception when loading an email that accesses this field
> 
>              Long emailid =
> Long.parseLong(request.getParameter("emailid"));
>              Email email = emailFacade.find(emailid);
>              html = email.getHtmlbody();
> 
> 
> My understanding was that this would automatically be loaded from the 
> database when/if needed
> 
> Any pointers would be greatly appreciated!!
> 
> 
> Derek
> 
> 
> 
> StandardWrapperValve[viewemail]: PWC1406: Servlet.service() for servlet 
> viewemail threw exception
> Local Exception Stack:
> Exception [EclipseLink-6004] (Eclipse Persistence Services - 1.0.2 
> (Build 20081024)): org.eclipse.persistence.exceptions.QueryException
> Exception Description: The object 
> [com.iTrac.Entity.Email[emailid=21444]], of class [class 
> com.iTrac.Entity.Email], with identity hashcode 
> (System.identityHashCode()) [15,615,811],
> is not from this UnitOfWork object space, but the parent session's.  The 
> object was never registered in this UnitOfWork,
> but read from the parent session and related to an object registered in 
> the UnitOfWork.  Ensure that you are correctly
> registering your objects.  If you are still having problems, you can use 
> the UnitOfWork.validateObjectSpace() method to
> help debug where the error occurred.  For more information, see the 
> manual or FAQ.
> Query: ReadObjectQuery(com.iTrac.Entity.Email)
>          at 
> org.eclipse.persistence.exceptions.QueryException.backupCloneIsOriginalFromParent(QueryException.java:237)
>          at 
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.getBackupClone(UnitOfWorkImpl.java:1752)
>          at 
> org.eclipse.persistence.descriptors.FetchGroupManager.writePartialIntoClones(FetchGroupManager.java:173)
>          at 
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3579)
>          at 
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3523)
>          at 
> org.eclipse.persistence.queries.ObjectBuildingQuery.registerIndividualResult(ObjectBuildingQuery.java:363)
>          at 
> org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:555)
>          at 
> org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:517)
>          at 
> org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:461)
>          at 
> org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:413)
>          at 
> org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:521)
>          at 
> org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:707)
>          at 
> org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:431)
>          at 
> org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:879)
>          at 
> org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:666)
>          at 
> org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:840)
>          at 
> org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:398)
>          at 
> org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:902)
>          at 
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2587)
>          at 
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1178)
>          at 
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1162)
>          at 
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1108)
>          at 
> org.eclipse.persistence.jpa.JpaHelper.loadUnfetchedObject(JpaHelper.java:200)
>          at com.iTrac.Entity.Email._persistence_checkFetched(Email.java)
>          at com.iTrac.Entity.Email._persistence_gethtmlbody(Email.java)
>          at com.iTrac.Entity.Email.getHtmlbody(Email.java:287)
>          at itrac.report.view.processRequest(view.java:41)
>          at itrac.report.view.doGet(view.java:75)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
>          at 
> org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
>          at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
>          at 
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
>          at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
>          at 
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
>          at 
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
>          at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
>          at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
>          at 
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
>          at 
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
>          at 
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
>          at 
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
>          at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
>          at 
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
>          at 
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
>          at 
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
>          at 
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
>          at 
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
>          at 
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
>          at 
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
>          at 
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
>          at 
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
>          at 
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
>          at 
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
>          at 
> com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
>          at 
> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
>          at 
> com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
> 
> On 02/25/10 14:18, Derek Knapp wrote:
>> thank you so much Tom!! that did exactly what I wanted.
>>
>> I knew it was possible for join's, but didn't know I could do it on a 
>> normal column!!
>>
>>
>> Derek
>>
>> On 02/25/10 13:50, Tom Ware wrote:
>>> Hi Derek,
>>>
>>>   Try simply specifying the LAZY fetch type on the annotation for 
>>> your mapping or in the orm.xml.
>>>
>>> e.g.
>>>
>>>     @Basic(fetch=FetchType.LAZY)
>>>
>>> -Tom
>>>
>>>
>>>
>>> Derek Knapp wrote:
>>>> I have a table, which I run a very simple select on, for example,
>>>>
>>>>     select e from Email e where e.createDate between :start and :end
>>>>
>>>> but the problem is that the Email has a column "body" which contains 
>>>> a lot of data, and I really don't need that information right 
>>>> now....  is there a way to make it not select that column?
>>>>
>>>> the only solution I can think of is to create a new class with the 
>>>> fields I want from the Email entity, then do something like
>>>>
>>>>     select new itrac.data.EmailReport(e.id, e.name, e.subject, ...) 
>>>> from Email e where e.createDate between :start and :end
>>>>
>>>> but is there a better way??
>>>>
>>>>
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Re%3A-select-part-of-an-entity-tp27762757p27837140.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top