Java JPA工具/EclipseLink-从实体生成表-列顺序
我试图使用Eclipse开普勒中的“JPA工具-->从实体生成表…”从现有带注释的实体生成ddl。当我运行任务时,我会得到一个包含sql脚本的文件来运行。问题在于表创建语句中列的顺序与类定义中属性的顺序不一致 例如:Java JPA工具/EclipseLink-从实体生成表-列顺序,java,sql,eclipse,jpa,eclipselink,Java,Sql,Eclipse,Jpa,Eclipselink,我试图使用Eclipse开普勒中的“JPA工具-->从实体生成表…”从现有带注释的实体生成ddl。当我运行任务时,我会得到一个包含sql脚本的文件来运行。问题在于表创建语句中列的顺序与类定义中属性的顺序不一致 例如: @Entity @Table(name = "news", catalog = "myDatabase") public class News implements java.io.Serializable { private long id; private
@Entity
@Table(name = "news", catalog = "myDatabase")
public class News implements java.io.Serializable {
private long id;
private String newsTitle;
private String newsTitle2;
private String newsText;
private Date created;
@Id
@GeneratedValue
@Column(name = "news_id", unique = true, nullable = false)
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
@Column(name = "news_title")
public String getNewsTitle() {
return this.newsTitle;
}
public void setNewsTitle(String newsTitle) {
this.newsTitle = newsTitle;
}
@Column(name = "news_title2")
public String getNewsTitle2() {
return this.newsTitle2;
}
public void setNewsTitle2(String newsTitle2) {
this.newsTitle2 = newsTitle2;
}
@Lob
@Column(name = "news_text")
public String getNewsText() {
return this.newsText;
}
public void setNewsText(String newsText) {
this.newsText = newsText;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created")
public Date getCreated() {
return this.created;
}
public void setCreated(Date created) {
this.created = created;
}
}
脚本:
创建表myDatabase.news(
新闻id BIGINT非空唯一,创建日期时间,新闻文本长文本,
新闻标题VARCHAR(255),新闻标题2 VARCHAR(255),主键(新闻id))
如何获得与java类对齐的列顺序的脚本
多谢各位
Stefano由于JPA中的抽象方法,这是不可能的。理论上,您不知道下面的数据库类型,也不知道那里的顺序是否重要。请参阅:和