在实体类上接缝@Name?
我第一次看到注释Seam实体类是在这里
http://www.developer.com/java/ejb/article.php/10931_3715171_5/Introducing-JBossreg-Seam.htm
出于某种原因我从那时起就一直这样做:
@Entity
@Table (name= "GADGET")
@Name("gadget")
public class GadgetBean implements Serializable {
private String mDescription = "";
private String mType = "";
...
}
但是,在我的观点中,我不会在任何地方使用这样的“实体组件”。谁能解释一下它的用途以及它的收益吗?难道是不修行吗?
I've first seen annotating Seam entity classes here
http://www.developer.com/java/ejb/article.php/10931_3715171_5/Introducing-JBossreg-Seam.htm
and for whatever reason I've been doing so ever since:
@Entity
@Table (name= "GADGET")
@Name("gadget")
public class GadgetBean implements Serializable {
private String mDescription = "";
private String mType = "";
...
}
However, I do not use "entity components" like this anywhere in my views. Can anyone explain the use of this and what this gains? Is it a non-practice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您未在视图中使用任何这些实体组件,则应删除 @Name 注释。
Seam 很棒,但是 Seam 组件会带来开销,因为每次访问该类中的方法时都会触发拦截器。由于您没有在视图中访问这些属性,因此无需将它们制作成接缝组件。每次使用实体 bean 中的 getter 或 setter 时,都会产生拦截器开销。
Seam-gen 是用于创建 Seam 项目的工具,它还可以生成从数据库表进行逆向工程的实体。默认情况下,seam-gen 实体生成器不会将 @Name 注释添加到这些类中。这应该告诉你一些事情!
希望这有帮助。
If you are not using any of these entity components in your views, you should remove the @Name annotation.
Seam is great, but seam components come with overhead in the way of interceptors firing every time you access a method in that class. Since you are not accessing these attributes in your view, there is no need to make them into seam components. You are incurring the interceptor overhead every time you use a getter or setter from your entity beans.
Seam-gen, the tool used to create seam projects, can also generate entities that are reverse-engineered from your database tables. By default, the seam-gen entity generator does NOT add the @Name annotation to these classes. That should tell you something!
Hope this helps.