Created
February 27, 2015 02:11
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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