4

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.

5
  • 7
    Test it on your own, local database. If it works fine, then only think about applying the change to production. You won't ask us for every little thing, won't you? Commented Jul 9, 2014 at 8:54
  • tiny int in MySQL is what boolean is in Java. Commented Jul 9, 2014 at 9:03
  • It works on local. I just hope there aren't any use cases I am missing . Thanks though. Commented Jul 9, 2014 at 9:06
  • 1
    Should be no problem, explicitly mentioned int - BIT(1) compatibility: dev.mysql.com/doc/ndbapi/en/mccj-using-clusterj-mappings.html Commented Jul 9, 2014 at 9:09
  • Can you please write in answer section so that I canmark it as correct answer?:) Commented Jul 9, 2014 at 9:17

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Here is an updated link to what @PVR was probably referring to
4

Go for the datatype Byte. it worked for me!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.