title: CGLIB Enhancement failed:argument type mismatch
body: <p>I`m getting following error:</p>
  
  <pre><code>Caused by: org.hibernate.HibernateException: CGLIB Enhancement failed: sk.statistics.isis.conceptsvocab.jpa.entities.VocabDomain
  at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:119)
  at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:72)
  at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
  at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
  at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:298)
  at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:219)
  at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
  at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
  at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
  at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
  at org.hibernate.type.EntityType.resolve(EntityType.java:412)
  at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
  at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
  at org.hibernate.loader.Loader.doQuery(Loader.java:752)
  at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
  at org.hibernate.loader.Loader.doList(Loader.java:2228)
  at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
  at org.hibernate.loader.Loader.list(Loader.java:2120)
  at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
  at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
  at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
  at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
  at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
  at sk.statistics.isis.conceptsvocab.adminmodule.services.impl.SubdomainsServiceImpl.getAllSubdomainLocalizationNamesForSpecificLocalization(SubdomainsServiceImpl.java:70)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
  at $Proxy31.getAllSubdomainLocalizationNamesForSpecificLocalization(Unknown Source)
  at sk.statistics.isis.conceptsvocab.adminmodule.ui.SubdomainsList.initContent(SubdomainsList.java:210)
  at sk.statistics.isis.conceptsvocab.adminmodule.mainWindow.MainPanel.selectWindowToDisplay(MainPanel.java:63)
  at sk.statistics.isis.conceptsvocab.adminmodule.mainWindow.MainPanel.access$0(MainPanel.java:50)
  at sk.statistics.isis.conceptsvocab.adminmodule.mainWindow.MainPanel$MainPanelListener.valueChange(MainPanel.java:98)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
  ... 26 more
  Caused by: java.lang.IllegalArgumentException: argument type mismatch
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.hibernate.repackage.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:616)
  at org.hibernate.repackage.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609)
  at org.hibernate.repackage.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java:578)
  at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyInstance(CGLIBLazyInitializer.java:129)
  at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:116)
  ... 69 more
  </code></pre>
  
  <p>VocabDomain listing:</p>
  
  <pre><code>/**
  * The persistent class for the VOCAB_DOMAINS database table.
  * 
  */
  @Entity
  @Table(name="VOCAB_DOMAINS")
  public class VocabDomain implements Serializable {
  
  /**
   * 
   */
  private static final long serialVersionUID = 202977208021067034L;
  private Long domainid;
  private Long optlockversion;
  private Set&lt;VocabDomainsLoc&gt; vocabDomainsLocs;
  private Set&lt;VocabSubdomain&gt; vocabSubdomains;
  
  public VocabDomain() {
  }
  
  
  @Id
  @SequenceGenerator(name="VOCAB_DOMAINS_DOMAINID_GENERATOR", sequenceName="SEQ_DOMAIN_ID")
  @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="VOCAB_DOMAINS_DOMAINID_GENERATOR")    
  public Long getDomainid() {
      return this.domainid;
  }
  
  public void setDomainid(Long domainid) {
      this.domainid = domainid;
  }
  
  @Version
  public Long getOptlockversion() {
      return this.optlockversion;
  }
  
  public void setOptlockversion(Long optlockversion) {
      this.optlockversion = optlockversion;
  }
  
  
  //bi-directional many-to-one association to VocabDomainsLoc
  @OneToMany(mappedBy="vocabDomain",fetch=FetchType.LAZY) 
  public Set&lt;VocabDomainsLoc&gt; getVocabDomainsLocs() {
      return this.vocabDomainsLocs;
  }
  
  public void setVocabDomainsLocs(Set&lt;VocabDomainsLoc&gt; vocabDomainsLocs) {
      this.vocabDomainsLocs = vocabDomainsLocs;
  }
  
  
  //bi-directional many-to-one association to VocabSubdomain
  @OneToMany(mappedBy="vocabDomain",fetch=FetchType.LAZY)
  public Set&lt;VocabSubdomain&gt; getVocabSubdomains() {
      return this.vocabSubdomains;
  }
  
  public void setVocabSubdomains(Set&lt;VocabSubdomain&gt; vocabSubdomains) {
      this.vocabSubdomains = vocabSubdomains;
  }
  
  @Override
  public boolean equals(Object other) {
      if (this == other) {
          return true;
      }
      if (!(other instanceof VocabDomain)) {
          return false;
      }
      if (this.getDomainid() == null) {
          return false;
      }       
      VocabDomain castOther = (VocabDomain) other;
      if (castOther.getDomainid() == null) {
          return false;
      }
      return this.getDomainid().equals(castOther.getDomainid());
  
  }
  
  @Override
  public int hashCode() {
      final int prime = 211;
      int hash = 223;
      hash = hash * prime + (this.getDomainid() != null ?     this.getDomainid().hashCode() : 1);
      return hash;
  }       
  }
  </code></pre>
  
  <p>The code fails during execution of this command:
      Query q = sessionFactory.getCurrentSession().createQuery("SELECT vsd FROM VocabSubdomain vsd LEFT JOIN vsd.vocabSubdomainsLocs");
      List vsdl = q.list();</p>
  
  <hr>
  
  <p>my dependencies in pom.xml</p>
  
  <pre><code>&lt;spring.version&gt;3.1.1.RELEASE&lt;/spring.version&gt;
  &lt;hibernate.version&gt;3.4.0.GA&lt;/hibernate.version&gt;
  
  
  &lt;dependencies&gt;
  
  &lt;dependency&gt;
      &lt;!-- na poradi zalezi --&gt;
      &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
      &lt;artifactId&gt;slf4j-jcl&lt;/artifactId&gt;
      &lt;version&gt;1.6.1&lt;/version&gt;
  &lt;/dependency&gt;
  
  
  &lt;dependency&gt;        
        &lt;groupId&gt;sk.statistics.isis.conceptsvocab.jpa&lt;/groupId&gt;
        &lt;artifactId&gt;ConceptsVocabJpa&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;/dependency&gt;
  
      &lt;!-- Spring dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-acl&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;   
  
      &lt;!--  Vaadin dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.vaadin&lt;/groupId&gt;
          &lt;artifactId&gt;vaadin&lt;/artifactId&gt;
          &lt;version&gt;${vaadin.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!--  J2EE dependencies --&gt;
  &lt;dependency&gt;
  &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
  &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
  &lt;version&gt;2.5&lt;/version&gt;
  &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
      &lt;!-- Portlet dependencies --&gt;       
      &lt;dependency&gt;
          &lt;groupId&gt;javax.portlet&lt;/groupId&gt;
          &lt;artifactId&gt;portlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.0&lt;/version&gt;
          &lt;scope&gt;${portal.scope}&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.portals.bridges&lt;/groupId&gt;
          &lt;artifactId&gt;portals-bridges-common&lt;/artifactId&gt;
          &lt;version&gt;2.0&lt;/version&gt;
      &lt;/dependency&gt;   
      &lt;!-- Ldap configuration start --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun&lt;/groupId&gt;
          &lt;artifactId&gt;ldapbp&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.ldap&lt;/groupId&gt;
          &lt;artifactId&gt;spring-ldap-core&lt;/artifactId&gt;
          &lt;version&gt;1.3.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Ldap configuration end --&gt;         
      &lt;!-- Hibernate configuration --&gt;
      &lt;dependency&gt;
        &lt;artifactId&gt;jta&lt;/artifactId&gt;
        &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
        &lt;version&gt;1.1&lt;/version&gt;
        &lt;scope&gt;${websphere.scope}&lt;/scope&gt;
        &lt;!--  TODO: pre profil na websphere tu treba dat provided --&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
        &lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;
        &lt;version&gt;${hibernate.version}&lt;/version&gt;
        &lt;!--  vynechaj jta transakcny management, websphere ma vlastny --&gt;
        &lt;exclusions&gt;
            &lt;exclusion&gt;
                &lt;artifactId&gt;jta&lt;/artifactId&gt;
                &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
            &lt;/exclusion&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;xml-apis&lt;/groupId&gt;
                &lt;artifactId&gt;xml-apis&lt;/artifactId&gt;
            &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
     &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
      &lt;version&gt;${spring.version}&lt;/version&gt;
     &lt;/dependency&gt;        
     &lt;dependency&gt;
        &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
        &lt;artifactId&gt;hibernate-cglib-repack&lt;/artifactId&gt;
        &lt;version&gt;2.1_3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;cglib&lt;/groupId&gt;
        &lt;artifactId&gt;cglib&lt;/artifactId&gt;
        &lt;version&gt;2.2.2&lt;/version&gt;
      &lt;/dependency&gt;   
      &lt;!-- Slf4j over commons logging --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;1.6.6&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;           
      &lt;!-- 
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
          &lt;version&gt;1.6.6&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;           
  &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-jdk14&lt;/artifactId&gt;
          &lt;version&gt;1.6.6&lt;/version&gt;
      &lt;/dependency&gt;
      --&gt; 
  &lt;dependency&gt;
      &lt;groupId&gt;log4j&lt;/groupId&gt;
      &lt;artifactId&gt;log4j&lt;/artifactId&gt;
      &lt;version&gt;1.2.16&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;/dependencies&gt;  
  </code></pre>