开发者

Hibernate ID column always last in generated SQL

开发者 https://www.devze.com 2023-03-29 18:06 出处:网络
I have a model that looks like this: @MappedSuperclass @AccessType(\"field\") public abstract class BaseEntity {

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

精彩评论

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