我有一个hibernate orm的实体,如下所示。在这个实体中,我不想持久化EntHesaplasma对象。所以我使用了@transient注释。
import javax.persistence.Transient;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "CARI_HAREKETLERI")
public class EntCariHareketler {
private Integer cha_RECno;
@Resolvable()
private EntHesaplasma enthesaplasma;
@Id
@GeneratedValue
@Column(name = "cha_recno", unique = true, nullable = false)
public Integer getCha_RECno() {
return cha_RECno;
}
@Transient
public EntHesaplasma getEnthesaplasma() {
return enthesaplasma;
}
public void setEnthesaplasma(EntHesaplasma enthesaplasma) {
this.enthesaplasma = enthesaplasma;
}
尽管我添加了@transient注释,但却出现了类似的错误
Could not determine type for: com.entity.EntHesaplasma, at table:
CARI_HAREKETLERI, for columns: org.hibernate.mapping.Column(enthesaplasma)]
感谢。
答案 0 :(得分:2)
也许你需要在现场定义它,而不是getter / setter
@Transient
private EntHesaplasma enthesaplasma;
答案 1 :(得分:0)
您无法随机将注释应用于方法或字段。通常,您应该以与@Id相同的方式应用注释。
在EntCariHareketler类中,Transients应该像
@Transient
private EntHesaplasma enthesaplasma;