Results 1 to 4 of 4

Thread: Hibernate configuration with cglib

  1. #1
    Join Date
    Aug 2004
    Location
    Montreal - Canada
    Posts
    46

    Default Hibernate configuration with cglib

    I try to set the Hibernate property 'hibernate.cglib.use_reflection_optimizer' to false:

    Code:
    <bean id="HibernateSessionFactory" 
     class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
      <property name="mappingResources">
         <list>
            <!-- This will include a list of all the mapping files 	to be used for this configuration. --> 
             &fileList; 
          </list>
       </property>
       <property name="hibernateProperties">
         <props>
            ....
            <prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
            <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
         </props>
       </property>
       <property name="dataSource">
           <ref local="DBDataSource"/>
       </property>
    </bean>
    but what ever the value of this property, Hibernate still uses cglib:

    Code:
    2004-09-28 19&#58;54&#58;59,642 &#91;main&#93; INFO  net.sf.hibernate.cfg.Environment - Hibernate 2.1.6
    2004-09-28 19&#58;54&#58;59,642 &#91;main&#93; INFO  net.sf.hibernate.cfg.Environment - hibernate.properties not found
    2004-09-28 19&#58;54&#58;59,642 &#91;main&#93; INFO  net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
    Does anyone knows how to disable the cglib optimizer?
    Christophe

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    hibernate.cglib.use_reflection_optimizer is a system level property.
    System-level properties are shared by all factory instances and are always determined by the Environment properties.
    The only system-level properties are
    hibernate.jdbc.use_streams_for_binary
    hibernate.cglib.use_reflection_optimizer
    Environment properties are populated by calling System.getProperties() and then from a resource named /hibernate.properties if it exists. System properties override properties specified in hibernate.properties.
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Oct 2007
    Location
    Berlin - Germany
    Posts
    6

    Default

    I tried both ways to disabled cglib in hibernate:

    I used the VM parameter:
    Code:
    -Dhibernate.bytecode.use_reflection_optimizer=false 
    -Dhibernate.cglib.use_reflection_optimizer=false
    I also created a hibernate.properties file in my classpath:
    Code:
    hibernate.bytecode.use_reflection_optimizer=false
    hibernate.cglib.use_reflection_optimizer=false
    Hibernate still uses cglib if i activate Spring AOP transaction handling in my application. Without AOP transaction handling cglib is not used.

    Can i disable usage of cglib in hibernate when i use Spring AOP transaction handling?
    ...and remember: code is poetry

  4. #4
    Join Date
    Mar 2009
    Posts
    6

    Default I solved

    I found a solution here:
    http://www.jroller.com/newm4n/entry/...tion_optimizer

    This error may be produced because hibernate is trying to set null to a property that is a primitive. Just change the property type to its wrapper (e.g. int -> Integer)

Similar Threads

  1. hibernate pool configuration
    By pg in forum Data
    Replies: 7
    Last Post: Oct 5th, 2005, 08:12 AM
  2. Replies: 5
    Last Post: Jul 13th, 2005, 07:02 PM
  3. Replies: 0
    Last Post: Jun 21st, 2005, 06:17 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Replies: 5
    Last Post: Aug 27th, 2004, 07:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •