空瞬态属性

发布于 2024-08-29 20:44:38 字数 321 浏览 3 评论 0原文

我有一个用 @PrePersist 注释进行注释的方法,但我发现当执行此方法时,我的所有瞬态属性(带有 @Transient 注释的属性)均为 null。

当我调试应用程序时,我可以看到在调用 persist() 方法之前此瞬态属性不为 null,并且当它进入我的 PrePersist 方法时,所有瞬态属性都更改为 null。

PostPersist 方法也会发生这种情况,我需要此方法中的瞬态信息。

这种行为正常吗? 如果不将此信息保存在数据库中,我可以避免这种情况吗?

如果它有帮助我使用 Hibernate 3.5 和 JPA 2。

谢谢

I have a method annotated with @PrePersist annotation but I've seen that when this method is executed all my transient attributes (the attributes with the @Transient annotation) are null.

When I debug the applicaion I can see that this transient attributes are not null just before calling the persist() method and when it enters my PrePersist method all transient attributes changes to null.

It also happens with PostPersist methods and I need the transient information in this methods.

Is this behaviour normal?
Can I avoid it without saving this information in my database?

If it helps I use Hibernate 3.5 and JPA 2.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗酒趁年少 2024-09-05 20:44:38

这类似于这个问题,它有更详细的答案。基本上瞬态信息会在幕后丢失。你对此无能为力。

This is similar to this question which has a more detailed answer. Basically transient information is lost under the hood. There isn't too much you can do about it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文