我对hibernate anotation有疑问。 我有一个BaseEntity.java和一个名为state.java的模型,它扩展了BaseEntity.java
BaseEntity.java.
@MappedSuperclass
public abstract class BaseEntity<T> implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private T id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CreatedBy", nullable = true)
private User createdBy;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "subsite", nullable = true)
private Subsite subsite;
}
state.java
@Entity
@Table(name="State")
public class State extends BaseEntity<Long> {
@Column(name = "state", nullable = true)
private String state;
@Column(name = "city", nullable = true)
private String city;
}
当程序在数据库中构建我的表时,我应该怎么做,像我的父类中设置的子网站一样的字段但是我的子类中没有设置 和hibernate忽略这个字段。
答案 0 :(得分:0)
您可以在declare @i int = 1
declare @rownumber int = 2
declare @result_set table (value varchar(1000))
declare @q_getoldeMail nvarchar(max)
declare @columnname varchar(100) = 'name'
declare @tablename varchar(100) = 'sys.columns'
--select * from sys.columns
Set @i = 1
While(@i <= @rowNumber)
BEGIN
Set @q_getoldeMail = 'SELECT Lower('+@columnname+') FROM (
SELECT ROW_NUMBER() OVER (ORDER BY object_ID) AS rownumber
,object_id
,name
FROM ' + (@tablename) + ') AS ar Where rownumber = '+convert(varchar,@i)+''
insert into @result_set
exec sp_executesql @q_getoldeMail
Set @i = @i+1
end
select * from @result_set
属性上使用@Transient
注释,但是您正在使用createdBy
注释,此引用被引用到另一个注册,因此无法为您的案例执行此操作,请参考至question获取更多信息。