title: JPA and Hibernate mapping with MySQL: Field 'describtion' doesn't have a default value
body: <p>I have the following Exception when i'm try to insert values in the database.
  This is my persistence class:</p>
  
  <pre><code>&lt;pre&gt; 
  @SuppressWarnings("serial")
  @Entity
  @Table(name = "consumer", catalog = "oauth")
  @NamedQueries({
      @NamedQuery(name = Consumer.QUERY_BY_CONSUMER_KEY, query = "SELECT i FROM " + Consumer.TABLENAME + " i WHERE i.consumerKey = :" + Consumer.Q_PARAM_CONSUMER_KEY)})
  public class Consumer implements java.io.Serializable {
  
      public static final String TABLENAME = "Consumer";
      public static final String QUERY_BY_CONSUMER_KEY = "ConsumerFindByConsumerKey";
      public static final String Q_PARAM_CONSUMER_KEY = "consumer_key";
      @Id
      @GeneratedValue(strategy = IDENTITY)
      @Column(name = "id", unique = true, nullable = false)
      private Integer id;
      @ManyToOne
      @JoinColumn(name = "user_id", nullable = false)
      private Idpuser idpuser;
      @Column(name = "description", nullable = false, length = 500)
      private String description;
      @Column(name = "consumer_key", nullable = false, length = 100)
      private String consumerKey;
      @Column(name = "consumer_secret", nullable = false, length = 100)
      private String consumerSecret;
      @Column(name = "callbackurl", nullable = false, length = 400)
      private String callbackURL;
      @Column(name = "request_token", length = 500)
      private String requestToken;
      @Column(name = "token_secret", length = 500)
      private String tokenSecret;
      @Column(name = "access_token", length = 500)
      private String accessToken;
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "acces_token_valid_from", length = 19)
      private Date accesTokenValidFrom;
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "access_token_valid_to", length = 19)
      private Date accessTokenValidTo;
      @Column(name = "access_token_num_usage_count")
      private Integer accessTokenNumUsageCount;
      @Column(name = "access_token_max_usage_count")
      private Integer accessTokenMaxUsageCount;
      @Column(name = "authorized", nullable = false)
      private Boolean authorized;
      @ManyToMany(fetch= FetchType.EAGER)
      @JoinTable(name = "consumer_role_relation",
      joinColumns = { 
        @JoinColumn(name = "consumer_id")
      }, 
      inverseJoinColumns = {
        @JoinColumn(name = "role_id")
      }
      )
      private Set&lt;Role&gt; roles = new HashSet&lt;Role&gt;(0);
  
      @Column(name = "facebookId", unique = true)
      private BigInteger facebookId;
  
  
      protected Consumer() {
      }
  
      public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
              String requestToken, String tokenSecret, String accessToken, boolean authorized) {
          this.idpuser = idpuser;
          this.description = describtion;
          this.consumerKey = consumerKey;
          this.consumerSecret = consumerSecret;
          this.callbackURL = callbackURL;
          this.requestToken = requestToken;
          this.tokenSecret = tokenSecret;
          this.accessToken = accessToken;
          this.authorized = authorized;
      }
  
      public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
              String requestToken, String tokenSecret, String accessToken, boolean authorized,
              Date accesTokenValidFrom, Date accessTokenValidTo, int accessTokenMaxUsageCount) {
          this.idpuser = idpuser;
          this.description = describtion;
          this.consumerKey = consumerKey;
          this.consumerSecret = consumerSecret;
          this.callbackURL = callbackURL;
          this.requestToken = requestToken;
          this.tokenSecret = tokenSecret;
          this.accessToken = accessToken;
          this.authorized = authorized;
          this.accesTokenValidFrom = accesTokenValidFrom;
          this.accessTokenValidTo = accessTokenValidTo;
          this.accessTokenMaxUsageCount = accessTokenMaxUsageCount;
      }
  
      public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
              String requestToken, String tokenSecret, String accessToken, boolean authorized,
              Date accesTokenValidFrom, Date accessTokenValidTo, int accessTokenMaxUsageCount, Set&lt;Role&gt; roles) {
          this.idpuser = idpuser;
          this.description = describtion;
          this.consumerKey = consumerKey;
          this.consumerSecret = consumerSecret;
          this.callbackURL = callbackURL;
          this.requestToken = requestToken;
          this.tokenSecret = tokenSecret;
          this.accessToken = accessToken;
          this.authorized = authorized;
          this.accesTokenValidFrom = accesTokenValidFrom;
          this.accessTokenValidTo = accessTokenValidTo;
          this.accessTokenMaxUsageCount = accessTokenMaxUsageCount;
          this.roles = roles;
      }
  
      public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
              String requestToken, String tokenSecret, String accessToken, boolean authorized,
              Date accesTokenValidFrom, Date accessTokenValidTo) {
          this.idpuser = idpuser;
          this.description = describtion;
          this.consumerKey = consumerKey;
          this.consumerSecret = consumerSecret;
          this.callbackURL = callbackURL;
          this.requestToken = requestToken;
          this.tokenSecret = tokenSecret;
          this.accessToken = accessToken;
          this.authorized = authorized;
          this.accesTokenValidFrom = accesTokenValidFrom;
      }
  
  
      public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
              String requestToken, String tokenSecret, String accessToken, boolean authorized,
              Date accesTokenValidFrom, Date accessTokenValidTo, Set&lt;Role&gt; roles) {
          this.idpuser = idpuser;
          this.description = describtion;
          this.consumerKey = consumerKey;
          this.consumerSecret = consumerSecret;
          this.callbackURL = callbackURL;
          this.requestToken = requestToken;
          this.tokenSecret = tokenSecret;
          this.accessToken = accessToken;
          this.authorized = authorized;
          this.accesTokenValidFrom = accesTokenValidFrom;
          this.roles = roles;
      }
  
  
      public Integer getId() {
          return this.id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public Idpuser getIdpuser() {
          return this.idpuser;
      }
  
      public void setIdpuser(Idpuser idpuser) {
          this.idpuser = idpuser;
      }
  
      public String getDescription() {
          return this.description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getConsumerKey() {
          return this.consumerKey;
      }
  
      public void setConsumerKey(String consumerKey) {
          this.consumerKey = consumerKey;
      }
  
      public String getConsumerSecret() {
          return this.consumerSecret;
      }
  
      public void setConsumerSecret(String consumerSecret) {
          this.consumerSecret = consumerSecret;
      }
  
      public String getCallbackURL() {
          return callbackURL;
      }
  
      public void setCallbackURL(String callbackURL) {
          this.callbackURL = callbackURL;
      }
  
      public Date getAccesTokenValidFrom() {
          return accesTokenValidFrom;
      }
  
      public void setAccesTokenValidFrom(Date accesTokenValidFrom) {
          this.accesTokenValidFrom = accesTokenValidFrom;
      }
  
      public String getAccessToken() {
          return accessToken;
      }
  
      public void setAccessToken(String accessToken) {
          this.accessToken = accessToken;
      }
  
      public Integer getAccessTokenMaxUsageCount() {
          return accessTokenMaxUsageCount;
      }
  
      public void setAccessTokenMaxUsageCount(Integer accessTokenMaxUsageCount) {
          this.accessTokenMaxUsageCount = accessTokenMaxUsageCount;
      }
  
      public Integer getAccessTokenNumUsageCount() {
          return accessTokenNumUsageCount;
      }
  
      public void setAccessTokenNumUsageCount(Integer accessTokenNumUsageCount) {
          this.accessTokenNumUsageCount = accessTokenNumUsageCount;
      }
  
      public Date getAccessTokenValidTo() {
          return accessTokenValidTo;
      }
  
      public void setAccessTokenValidTo(Date accessTokenValidTo) {
          this.accessTokenValidTo = accessTokenValidTo;
      }
  
      public Boolean getAuthorized() {
          return authorized;
      }
  
      public void setAuthorized(Boolean authorized) {
          this.authorized = authorized;
      }
  
      public String getRequestToken() {
          return requestToken;
      }
  
      public void setRequestToken(String requestToken) {
          this.requestToken = requestToken;
      }
  
      public String getTokenSecret() {
          return tokenSecret;
      }
  
      public void setTokenSecret(String tokenSecret) {
          this.tokenSecret = tokenSecret;
      }  
  
      public Set&lt;Role&gt; getRoles(){
          return this.roles;
      }
  
      public void setRoles(Set&lt;Role&gt; roles){
          this.roles = roles;
      }
  
      public void addRole(Role r){
          this.roles.add(r);
      }
  
      public void removeRole(Role r){
          this.roles.remove(r);
      }
  
      @Override
      public String toString(){
          return this.description;
      }
  
  
  
      /* (non-Javadoc)
       * @see java.lang.Object#hashCode()
       */
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result
                  + ((consumerSecret == null) ? 0 : consumerSecret.hashCode());
          return result;
      }
  
      /* (non-Javadoc)
       * @see java.lang.Object#equals(java.lang.Object)
       */
      @Override
      public boolean equals(Object obj) {
          if (this == obj)
              return true;
          if (obj == null)
              return false;
          if (getClass() != obj.getClass())
              return false;
          Consumer other = (Consumer) obj;
          if (consumerSecret == null) {
              if (other.consumerSecret != null)
                  return false;
          } else if (!consumerSecret.equals(other.consumerSecret))
              return false;
          return true;
      }
  
  
  
      /* ###### Listener handling ###########################  */
      @Transient
      private CopyOnWriteArrayList&lt;Object&gt; listeners = new CopyOnWriteArrayList&lt;Object&gt;();
  
      public CopyOnWriteArrayList&lt;Object&gt; getListeners() {
          return listeners;
      }
  
      public void setListeners(CopyOnWriteArrayList&lt;Object&gt; listeners) {
          this.listeners = listeners;
      }
  
      public BigInteger getFacebookId() {
          return facebookId;
      }
  
      public void setFacebookId(BigInteger facebookId) {
          this.facebookId = facebookId;
      }    
  }
  
  &lt;/pre&gt;
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>&lt;pre&gt;
  Dez 03, 2011 12:58:21 PM org.hibernate.util.JDBCExceptionReporter logExceptions
  Warnung: SQL Error: 1364, SQLState: HY000
  Dez 03, 2011 12:58:21 PM org.hibernate.util.JDBCExceptionReporter logExceptions
  Schwerwiegend: Field 'describtion' doesn't have a default value
  Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [org.idp.persistence.mappings.Consumer]
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
      at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:695)
      at org.idp.persistence.DataManager.saveOrUpdateEntity(DataManager.java:224)
      at org.idp.persistence.DataManager.saveOrUpdate(DataManager.java:142)
      at org.idp.persistence.mappings.Idpuser.addOrUpdateConsumer(Idpuser.java:259)
      at org.idp.playground.ReadTest.main(ReadTest.java:40)
  &lt;/pre&gt;
  </code></pre>
  
  <p>When i'm try to read from database it's work. It is also working when i'm try to insert data into another Table (e.g. Idpuser). I'm also tried following solution advices:</p>
  
  <ul>
  <li>set default value for the description field in the database</li>
   - 
  </ul>