Tiny int of MySQL to Integer in Java

hibernate, java, mysql

Solution

JDBC driver maps databse type to java. So in case of mysql `TINYINT` will be converted to `java.lang.Boolean` or `java.lang.Integer`.

Refer this link which explains : Java, JDBC and MySQL Types

Problem

I have an `tiny int` column in MySQL. I want to convert it into int type of java. So if I mention the column in my hibernate entity as ``` @Column(name="Columname") private int something; ``` Will it cause an error as tiny int needs boolean type or will it get cast into int? This code will be changed in production Db hence I cannot check it to see if it breaks.

Original source