What is replacement of getTypeName() in DIalect class of Hibernate

I have been tasked to upgrade a Java project, and now in the Hibernate package, there was a function dialect.getTypeName() but now it is giving me undefined after upgrading to 6.6.6 I don’t want to go back I need alternatives. below is my function call

dialect.getTypeName(-16, 255, 0, 0)

but I am getting error getTypeName is not defined. I have searched and have found that it has been moved to Jdbc but I could not found any way what will do the exact same thing the above code can

You should use org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry#getTypeName(int, org.hibernate.engine.jdbc.Size, org.hibernate.type.Type).

Ok, thank you very much for your response kindly can you help me do this? I mean how to initialize DdlTypeRegistry, Size and Type and how to combine them all to get the type name? It will be a great help if I can get a simple code example. Note that in my code dialect is of type Dialect I actually made a generic class where user choses their database so it is of default parent class

You can get the DdlTypeRegistry from TypeConfiguration, which you can get from several places e.g. org.hibernate.engine.spi.SessionFactoryImplementor#getTypeConfiguration. Size you should just instantiate yourself, and Type should be optional in most cases, otherwise you can get it from Hibernate’s org.hibernate.mapping.Value#getType().

Alternatively, you can also use org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry#getTypeName(int, org.hibernate.dialect.Dialect) to get the type name from a java.sql.Types JDBC code.

Out of curiosity what output will be given by dialect.getTypeName(-16, 255, 0, 0)? Is it LONGVARCHAR or TEXT datatype?

Try it yourself if you’re so curious :wink: