Hello,
I'm trying to specify a property in my entity bean (called Appendix) as lazy
loaded by the following annotations:
| @Lob
| @Basic(fetch = FetchType.LAZY)
| @Column(name = "DOCUMENT", nullable = true)
| public byte[] getDocument() {
| return this.document;
| }
|
What I want is that this property ISN'T loaded unless I access it within the
scope of the entity manager. When I search for an Appendix entity bean in the
database using a EJB-QL query like:
| // Create traffic type query
| final EntityManager theEntityManager = this.getEntityManager();
| final Query theTrafficTypeQuery = theEntityManager.createQuery("from
Appendix a where a.trafficType = :trafficType");
| theTrafficTypeQuery.setParameter("trafficType", theTrafficType);
| final List<Appendix> theAppendixes = theTrafficTypeQuery.getResultList();
|
I can see in the JBoss log that the property "DOCUMENT" gets loaded anyway.
| select appendix0_.APPENDIX_ID as APPENDIX1_0_, appendix0_.START_DATE as
START2_0_, appendix0_.DESCRIPTION as DESCRIPT3_0_, appendix0_.DOCUMENT as
DOCUMENT0_, appendix0_.EXTENSION_ID as EXTENSION9_0_, appendix0_.CREATE_DATE as
CREATE5_0_, appendix0_.PAGE_ID as PAGE6_0_, appendix0_.PRODUCT_ID as
PRODUCT7_0_, appendix0_.STOP_DATE as STOP8_0_ from APPENDIX appendix0_ where
appendix0_.PRODUCT_ID=?
|
Does anyone know how I get my byte array property lazy loaded?
If I understand it correct, loading lazy loaded entities should use the
EntityManager method getReference(...), but in my case I load the entities
using a query.
In the following Hibernate reference docs I've read something about
instrumentation, is it really necessary?
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#performance-fetching-lazyproperties.
I've really tried to search the forum but doesn't find anything useful.
I'm using JBoss 4.0.4 GA and EJB3.0RC6.
Regards, Andreas
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973531#3973531
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973531
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user