-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Doubt about interception and instrumented bytecode
PostPosted: Fri Mar 25, 2011 12:45 pm 
Newbie

Joined: Fri Mar 25, 2011 10:56 am
Posts: 2
I've an entity which I recently added a new blob property and I want only that property to be loaded lazily via interception, so I set the lazy attribute of the property mapping true and used the ant task (org.hibernate.tool.instrument.cglib.InstrumentTask) in order to instrument the bytecode of the entity, this is for example:

Class
Code:
...
public class Category implements Serializable {
   ...
   private byte[] image;
   ...
   public byte[] getImage(){
      return this.image;
   }

   public void setImage(byte[] image){
      this.image = image;
   }
   ...
}


Mapping
Code:
    <class name="app.domain.Category" table="category">
        <id name="code" column="code" type="int" unsaved-value="0">
            <generator class="native">
                <param name="sequence">s_category</param>
            </generator>
        </id>
        ...
        <property name="level" type="int" column="level" />
        ...
        <property name="image" type="blob" column="image" not-null="false" lazy="true" />
        ...
    </class>


Ant log
Code:
[instrument] starting instrumentation
...
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.name]
[instrument] accepting transformation of field access [app.domain.Category.name]
[instrument] accepting transformation of field access [app.domain.Category.level]
[instrument] accepting transformation of field access [app.domain.Category.level]
...
[instrument] accepting transformation of field access [app.domain.Category.image]
[instrument] accepting transformation of field access [app.domain.Category.image]
...
[instrument] accepting transformation of field access [app.domain.Category.image]
[instrument] accepting transformation of field access [app.domain.Category.image]
...
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.level]
[instrument] accepting transformation of field access [app.domain.Category.name]
...
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.name]
...
[instrument] accepting transformation of field access [app.domain.Category.level]
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.code]
[instrument] accepting transformation of field access [app.domain.Category.code]
...
[instrument] accepting transformation of field access [app.domain.Category.name]
...


How you can see the log shows the properties more than once, its that ok?

The main doubt is why other properties other than the image blob are instrumented?, I just want that property to be instrumented and the other to stay as they has been working.

Any hint will be appreciate


Top
 Profile  
 
 Post subject: Re: Doubt about interception and instrumented bytecode
PostPosted: Sun Mar 27, 2011 6:48 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
if you instrument a class, you instrument it completely. That doesn't mean that the other fields turn lazily as well, the options from your annotations will be respected.
Actually instrumenting all your entities might provide you with some extra performance.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Doubt about interception and instrumented bytecode
PostPosted: Sun Mar 27, 2011 9:22 pm 
Newbie

Joined: Fri Mar 25, 2011 10:56 am
Posts: 2
That's ok for me, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.