hibernate

Hibernate Proxy InstantiationException

Changing entities to be lazy loaded led me to the following problem:

@OneToMany(fetch = FetchType.LAZY)
Caused by: org.hibernate.HibernateException: Javassist Enhancement failed: Thing
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:142)
	at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
	at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
….
Caused by: java.lang.InstantiationException: Thing_$$_javassist_38
	at java.lang.Class.newInstance0(Class.java:340)
	at java.lang.Class.newInstance(Class.java:308)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)

Thanks to Kristian I jumped straight to the problem. From the Hibernate docs:

Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with at least package visibility for runtime proxy generation in Hibernate.

This should probably read “It is essential….”

Anyway now everything is real lazy so happy days.

  • Share/Bookmark

hibernate

Comments (0)

Permalink

Log4J settings for working with Hibernate


	
	
  		
	
	
  		
	
	
  		
	
	

	

  • Share/Bookmark

hibernate

Comments (0)

Permalink

Hibernate components and relationships

Situation: you have a hibernate component which itself has a link to another object (e.g. many-to-one)

When loading, if hibernate is not able to satisfy the dependency, it will NOT set the field for your component.

e.g. we have :



    
        
    


  • Share/Bookmark

code
hibernate

Comments (0)

Permalink