Skip to content

Instantly share code, notes, and snippets.

@yusuke2255
Created February 27, 2015 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yusuke2255/ca42fc94181c6382665a to your computer and use it in GitHub Desktop.
Save yusuke2255/ca42fc94181c6382665a to your computer and use it in GitHub Desktop.
【メモ】Hibernateでinsert時にprimary keyでauto incrementを指定している時 ref: http://qiita.com/Kawata/items/62cbe83789b5a3c94bf7
ERROR [2015-02-27 11:01:38,781] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: ef46ad41b77903a3
! com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'hoge.hibernate_sequence' doesn't exist
! at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_20]
package hoge.bean;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.joda.time.DateTime;
@Entity
@Table(name="hoge_table")
public class HogeTable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY) // これをつけて解決
@Column(name="id")
private Integer id;
@Column(name="created")
private DateTime created;
@Column(name="modified")
private DateTime modified;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public DateTime getCreated() {
return created;
}
public void setCreated(DateTime created) {
this.created = created;
}
public DateTime getModified() {
return modified;
}
public void setModified(DateTime modified) {
this.modified = modified;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment