title: How can a javax.persistence.Column be defined as an Unsigned TINYINT?
body: <p>I am creating a Java Persistence Entity Bean (with NetBeans IDE 8.0.1) based on an existing table in a MySQL database. I've come across a field in this table which is of type <em>"Unsigned TINYINT(3)"</em>. I have found that the following can be done to <a href="https://stackoverflow.com/a/5261992/2541501">define the type of a column as an unsigned int</a>:</p>
  
  <pre><code>private long foo;
  
  @Column(columnDefinition = "UNSIGNED INT(11)")
  public long getFoo()
  {
      return foo;
  }
  </code></pre>
  
  <h1>Steps to reproduce the problem:</h1>
  
  <p>I am trying to create a field as follows:</p>
  
  <pre><code>@Size(max = 3)
  @Column(name = "WorkingHours", columnDefinition="UNSIGNED TINYINT(3) default '40'")
  private Integer workingHours;
  </code></pre>
  
  <h1>The problem:</h1>
  
  <p>I receive the following error when deploying my project to my server:</p>
  
  <pre><code>{"JBAS014671: Failed services" =&gt; {"jboss.persistenceunit.\"my-project.ear/my-project-ejb.jar#old-db\"" =&gt; "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"my-project.ear/my-project-ejb.jar#old-db\": javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table ... etc.]
      Caused by: javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table ... etc.]
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED TINYINT(3), ... etc.' at line 1"}}
  </code></pre>
  
  <p>If I however remove <em>"UNSIGNED"</em> from my <code>columnDefinition</code> (so the line becomes <code>columnDefinition="TINYINT(3) default '40'"</code>) deployment of my project is successful. So it seems that <em>"UNSIGNED"</em> is not recognized.</p>
  
  <p>So my question is: <em>how do I define my column (field) as an unsigned TINYINT?</em></p>
  
  <h1>Some more details:</h1>
  
  <p>I'm not sure if it is important, but my <em>persistence.xml</em> file looks as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"&gt;
    &lt;persistence-unit name="old-db" transaction-type="JTA"&gt;
      &lt;jta-data-source&gt;java:/jboss/datasources/mySQL_pool_old&lt;/jta-data-source&gt;
      &lt;properties&gt;
        &lt;property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>