[英]Why does hibernate give me this error when I put the transient tag?
I am trying to fix the vulnerabilities that Kiuwan is indicating to me.我正在尝试修复 Kiuwan 向我指出的漏洞。
The problem is that one of them is adding the Transient type to a Date type variable, when I do it it gives me the following error.问题是其中之一是将 Transient 类型添加到 Date 类型变量,当我这样做时它会给我以下错误。
Caused by: org.hibernate.AnnotationException: com.pack.keys.MyClassKey has no persistent id property: com.pack.logic.MyClass.id
If i dont put transient in Date dont show the error and my project compile.如果我不在日期中放置瞬态,则不会显示错误并且我的项目会编译。
@Table(name = "tablename")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class MyClass{
@EmbeddedId
private MyClassKey id;
private String string1;
//Many String more...
@Embeddable
@AllArgsConstructor
@NoArgsConstructor
@Data
public class MyClassKey implements Serializable {
private static final long serialVersionUID = 1L;
private transient String string1;
private transient String string2;
private transient String string3;
@Temporal(TemporalType.TIMESTAMP)
private transient Date myDate;
}
Thanks.谢谢。
Because transient is excluding attributes from Hibernate. It has the same effect as adding @Transient
annotation:因为transient排除了Hibernate中的属性,和添加@Transient
注解效果一样:
https://javaee.github.io/javaee-spec/javadocs/javax/persistence/Transient.html https://javaee.github.io/javaee-spec/javadocs/javax/persistence/Transient.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.