java - How to create Tinyint Field in Hibernate annotation -
I have trouble creating tint fields in the MySQL database using hibernate.
I write the unit
@enti
@Table (name = "tablename")
Public square mainity {
Private Int id; @ ID @ Generated Values (strategy = generation type AOTO) @column (name = "id") public ITIID () {return id; } Public Zero setId (int id) {this.id = id; }
}
}
And when I check MySQL, the id field always ends with an integer (11) So how can I make it as a tinjin?
Any answer will be appreciated
I think that There are a few ways. To use the first column column definition to use on the @column annotation:
@column (name = "id", columnDefinition = "TINYINT")
It is not portable in the database and does not align the variable with itself as an int as well. A byte or small may be required here
Another method is @ type appation Is to use, possibly with org.hibernate.type.ByteType, because it seems to represent a tinet () Is.
I hope it helps.
Comments
Post a Comment