Mayank_Thapliyal
Mayank_Thapliyal

Reputation: 371

Tiny int of MySQL to Integer in Java

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.

Upvotes: 4

Views: 30108

Answers (2)

PVR
PVR

Reputation: 915

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

Upvotes: 4

Vishal_Kotecha
Vishal_Kotecha

Reputation: 491

Go for the datatype Byte. it worked for me!

Upvotes: 4

Related Questions