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
?
精彩评论