Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Lob field fetch=FetchType.LAZY being ignored
Lob field fetch=FetchType.LAZY being ignored [message #683321] Mon, 13 June 2011 14:15 Go to next message
William Korb is currently offline William KorbFriend
Messages: 7
Registered: January 2011
Junior Member
I am working with a SQL Server 2008 database which has a table that includes a field of type "image" (which EclipseLink recognizes as a LOB).

I used the NetBeans "create entity from database" wizard to generate the class that models this table, and the generated information for this LOB field looked like this:
  @Basic(optional = false)
  @Lob
  @Column(name = "ORDER_DATA")
  private Serializable	orderData;

The LOB field happens to be a complex serialized Java object, so when the EL runtime loads this table and gets to this field, it tries to deserialize the entire field. As such, the classes for all of the constituent fields of the serialized object are required to be on my classpath. The JARs required to satisfy this requirement are numerous and large.

The data in this field is something that I would really never do anything with, so having this requirement for my classpath adds lots of unnecessary complexity to the project as well as a dependency on an external project that I have no control over.

My first thought was to force this field to be lazy loaded, thinking that if the RT did not load this field, it would not discover that it needed these other classes and I could just leave them off of my classpath. As such, I modified my mapping as such:
  @Basic(optional = false, fetch=FetchType.LAZY)
  @Lob
  @Column(name = "ORDER_DATA")
  private Serializable	orderData;

I then removed the jars for the classes contained in this column from my classpath, but when I attempt to load a record from the database, it complains:
Local Exception Stack: 
Exception [EclipseLink-66] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Could not deserialize object from byte array.
Internal Exception: Exception [EclipseLink-3007] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [com.whatever.SomeClass], of class [class java.lang.String], could not be converted to [class java.lang.Class].  Ensure that the class [com.whatever.SomeClass] is on the CLASSPATH.  You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager
Internal Exception: java.lang.ClassNotFoundException: com.whatever.SomeClass

What am I missing here? How can I tell the EL runtime to completely disregard this field?

Thanks,
Bill
Re: Lob field fetch=FetchType.LAZY being ignored [message #683335 is a reply to message #683321] Mon, 13 June 2011 14:43 Go to previous messageGo to next message
Gordon Yorke is currently offline Gordon YorkeFriend
Messages: 78
Registered: July 2009
Member
If this Entity will not need access to this column then simply remove the attribute from your Entity. Not all columns need to be mapped in your Entity, any can be safely ignored.
Re: Lob field fetch=FetchType.LAZY being ignored [message #683362 is a reply to message #683335] Mon, 13 June 2011 15:33 Go to previous message
William Korb is currently offline William KorbFriend
Messages: 7
Registered: January 2011
Junior Member
That's an excellent suggestion, and I had thought about doing exactly that. The reason why I didn't was that I was concerned that at some future time someone might want to use that field for something, and had I not included it in the mapping, they would need a different version of the entity to do what they wanted.

What's really strange about this, too, is that the ClassNotFoundExceptions don't happen every time I process one of the records in this table. They only happen about 25% of the time, and the other 75% my code works perfectly. Why would the EL runtime sometimes inspect the data in this LOB and want to deserialize it, and sometimes not? I mean that a single, specific record can be queried from the table, and only 25% of the time will that record cause a CNFE.

With that said, since I don't need to use this field now, I've gone the path or least resistance and removed that field from my entity, and now it works reliably. I'm still thinking there may be some bug in the way EL is handling lazy loading, but I guess that's something to deal with some other time.

Bill
Previous Topic:(no subject)
Next Topic:EclipseLink caching and Oracle Workspace Manager
Goto Forum:
  


Current Time: Thu Mar 28 17:20:36 GMT 2024

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

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

Back to the top