Problem
When you query data by using Hibernate with the Java Database Connectivity (JDBC) driver for Tablestore, the following error occurs:
Exception in thread "main" org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:108)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:133)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:322)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:485)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:286)Cause
The javassist-x.x.x.jar package is missing from your project's classpath.
Hibernate uses javassist for runtime bytecode manipulation to generate dynamic proxies for entity classes. These proxies enable lazy loading and dirty checking. Without javassist, Hibernate cannot create PojoEntityTuplizer instances, and the query fails.
Solution
Add the javassist library to your project by using one of the following methods.
Method 1: Add a Maven dependency
Add the following dependency to the <dependencies> block in your pom.xml file. This example uses version 3.15.0-GA.
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.15.0-GA</version>
</dependency>Method 2: Download and import the JAR manually
Download the
javassist-x.x.x.jarfile from Maven Repository, wherex.x.xis the version number. Choose a version based on your project requirements.Import the downloaded JAR into your project.
Verify the fix
After you add the javassist dependency, rebuild your project and re-run the query. The Unable to instantiate default tuplizer error no longer appears.