Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jpa mapping java type to database type

Every JPA-Provider (at least hibernate, eclipselink and openjpa) gives the possibility to create the ddl-schema on the basis of the jpa entity classes. But every database management system has his own data types.

So how do the jpa-providers decide which sql datatype will be chosen. (I think it will be provider specific). Is there a Mapping like String->varchar(xx), boolean->tinyint and so on. But then this mapping has to be exist for every database, right? Can anyone put me in the right direction please? I searched in the hibernate source-code but I did not find the right code snippets.

Thanks!

like image 628
user985705 Avatar asked Nov 13 '22 20:11

user985705


1 Answers

then this mapping has to be exist for every database, right?

You are right. The same is specified in the Dialect which is being used in DB connections.

For whatever I have searched this information is encapsulated inside the dialect driver for the DB which you use and the same must contain the mapping of java types -> db types.

Here you can see mapping in Constructor.

like image 59
Bharat Sinha Avatar answered Nov 15 '22 13:11

Bharat Sinha