开发者

Hibernate ID column always last in generated SQL

I have a model that looks like this:

@MappedSuperclass
@AccessType("field")
public abstract class BaseEntity {
    @Id
    @GeneratedValue(strategy = Genera开发者_JAVA技巧tionType.AUTO, generator = "generator")
    @Column(name = "ID")
    private Long id;
}

@Entity
@Table(name = "MODEL")
@AccessType("field")
public class Model extends BaseEntity {
    @Column(name="ABC")
    private String abc;
}

No matter what I try I cannot seem to be able to move the location of the ID column in the generated INSERT or UPDATE sql queries. ID always ends up as the last column:

insert into MODEL (ABC, ID) values (?, ?)

Is there any way to force it otherwise?


This is a known Hibernate limitation; see this thread for details.

Since Hibernate will order generated SQL fields alphabetically, why not change the name of the CLOB field to ensure is comes last, such as by pre-pending it with "zzz" so that it becomes zzzAbc?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜