# How to fix BasicTypeImpl cannot cast to BasicPluralType, Can debug?

**URL:** <https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156>\
**Category:** Hibernate ORM\
**Created:** [August 20, 2024, 12:23am UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156 "2024-08-20T00:23:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezuo](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@ezuo](https://discourse.hibernate.org/u/ezuo)\
**Post date:** [August 20, 2024, 12:23am UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156/1 "2024-08-20T00:23:04Z")

</div>

Hello,  
As a new Hibernate, after days struggling, I fixed some errors in mapping and annotations. It is a very old applications, an entity contains multiple other entities, sometimes hard to identify a entity. The following exception says :

```auto
class org.hibernate.type.internal.BasicTypeImpl cannot be cast to class org.hibernate.type.BasicPluralType

```

Error occurred without execute a good SQL. I think it relates to entity settings, too vague. but show me the path. I tried to debug in vain.  
Could somebody teach me, when Debug, is it possible to step into a function, Watch a Expressions, we can get the entity name?

```auto
Initial SessionFactory creation failed.java.lang.ClassCastException: class org.hibernate.type.internal.BasicTypeImpl cannot be cast to class org.hibernate.type.BasicPluralType (org.hibernate.type.internal.BasicTypeImpl and org.hibernate.type.BasicPluralType are in unnamed module of loader 'app')
java.lang.ClassCastException: class org.hibernate.type.internal.BasicTypeImpl cannot be cast to class org.hibernate.type.BasicPluralType (org.hibernate.type.internal.BasicTypeImpl and org.hibernate.type.BasicPluralType are in unnamed module of loader 'app')
	at org.hibernate.type.descriptor.sql.internal.ArrayDdlTypeImpl.getCastTypeName(ArrayDdlTypeImpl.java:34)
	at org.hibernate.sql.ast.spi.AbstractSqlAstTranslator.getCastTypeName(AbstractSqlAstTranslator.java:6992)
	at org.hibernate.sql.ast.spi.AbstractSqlAstTranslator.visitCastTarget(AbstractSqlAstTranslator.java:6939)
	at org.hibernate.sql.ast.tree.expression.CastTarget.accept(CastTarget.java:80)
	at org.hibernate.sql.ast.spi.AbstractSqlAstTranslator.render(AbstractSqlAstTranslator.java:7073)
	at org.hibernate.query.sqm.produce.function.internal.PatternRenderer.render(PatternRenderer.java:224)
	at org.hibernate.query.sqm.produce.function.internal.PatternRenderer.render(PatternRenderer.java:159)
	at org.hibernate.query.sqm.produce.function.internal.PatternRenderer.render(PatternRenderer.java:142)
	at org.hibernate.dialect.function.CastFunction.render(CastFunction.java:76)
	at org.hibernate.sql.ast.spi.AbstractSqlAstTranslator.renderCasted(AbstractSqlAstTranslator.java:5813)
	at org.hibernate.dialect.OracleSqlAstTranslator.renderMergeSource(OracleSqlAstTranslator.java:695)
	at org.hibernate.dialect.SqlAstTranslatorWithUpsert.renderMergeUsing(SqlAstTranslatorWithUpsert.java:92)
	at org.hibernate.dialect.SqlAstTranslatorWithUpsert.renderUpsertStatement(SqlAstTranslatorWithUpsert.java:66)
	at org.hibernate.dialect.SqlAstTranslatorWithUpsert.createMergeOperation(SqlAstTranslatorWithUpsert.java:36)
	at org.hibernate.dialect.OracleDialect.createOptionalTableUpdateOperation(OracleDialect.java:1588)
	at org.hibernate.sql.model.internal.OptionalTableUpdate.createMutationOperation(OptionalTableUpdate.java:144)
	at org.hibernate.persister.entity.mutation.AbstractMutationCoordinator.createOperationGroup(AbstractMutationCoordinator.java:87)
	at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.buildStaticUpdateGroup(UpdateCoordinatorStandard.java:1663)
	at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.<init>(UpdateCoordinatorStandard.java:93)
	at org.hibernate.persister.entity.mutation.MergeCoordinator.<init>(MergeCoordinator.java:23)
	at org.hibernate.persister.entity.AbstractEntityPersister.buildMergeCoordinator(AbstractEntityPersister.java:3658)
	at org.hibernate.persister.entity.AbstractEntityPersister.doLateInit(AbstractEntityPersister.java:3404)
	at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3690)
	at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:202)
	at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:371)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:300)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:457)
	at com.eng.maris.utility.HibernateUtil.getSessionFactory(HibernateUtil.java:29)
	at com.eng.maris.dao.AbstractDAO.<init>(AbstractDAO.java:79)

```

Thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![mbladel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbladel/32/2128_2.png) [@mbladel](https://discourse.hibernate.org/u/mbladel)\
**Post date:** [August 20, 2024, 8:17am UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156/2 "2024-08-20T08:17:17Z")

</div>

Hello, you could set a break point in `OracleSqlAstTranslator#renderMergeSource` to see which path is causing this error to be thrown when Hibernate tries to render a casted expression.

What version of Hibernate are you using? From the line numbers in the stack trace, it does not look like you’re on the latest version. Please consider upgrading to the [latest stable](https://hibernate.org/orm/releases/) version to see if the issue persists.

---

<div class="post-metadata">

**Author:** ![ezuo](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@ezuo](https://discourse.hibernate.org/u/ezuo)\
**Post date:** [August 20, 2024, 3:58pm UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156/3 "2024-08-20T15:58:34Z")

</div>

Hi mbladel,  
Thank you for the reply. The error I posted is with Hibernate 6.5.2. I just changed it to 6.4.9 and delete /repository from C:\Users\ezuo.m2, to force maven to reload libs. then I got the same error . 6.4.9 was the latest stable version when I first started hibernate in June. I changes so fast.  
Following your instruction, I am going to debug.  
Thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![ezuo](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@ezuo](https://discourse.hibernate.org/u/ezuo)\
**Post date:** [August 21, 2024, 5:44pm UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156/4 "2024-08-21T17:44:58Z")

</div>

Hi mbladel,  
As you pointed, I find the problem and did a fix. it resolved.  
Thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![ushhaha](https://avatars.discourse-cdn.com/v4/letter/u/f1d935/32.png) [@ushhaha](https://discourse.hibernate.org/u/ushhaha)\
**Post date:** [November 7, 2024, 3:49am UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156/6 "2024-11-07T03:49:30Z")

</div>

Can someone tell me what was the solution? I am facing same issue. We are using spring-boot 3.3.0 and hibernate-6.5.2 which is part of spring boot. If you post what was the fix you did that would be really grateful

---

<div class="post-metadata">

**Author:** ![ushhaha](https://avatars.discourse-cdn.com/v4/letter/u/f1d935/32.png) [@ushhaha](https://discourse.hibernate.org/u/ushhaha)\
**Post date:** [November 8, 2024, 3:38pm UTC](https://discourse.hibernate.org/t/how-to-fix-basictypeimpl-cannot-cast-to-basicpluraltype-can-debug/10156/7 "2024-11-08T15:38:41Z")

</div>

@ezuo Can you please share your solution?
