• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Annotated entities as DTOs

 
al nik
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

what about sharing the annotated entities outside the business tier? If I want to use my entity as a DTO but I don't want to share all my DB mapping config... my only way is to use XML? I'm imaging a situation where I have a domain project that is used by others like webapp proj. or standalone proj.

thanks
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, then your only way is to use XML mapping instead of Annotations.
 
al nik
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Jothi
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess we need to think of some pattern that might help us keep the annotation and port the same entity to the client.
 
al nik
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know, I don't see any pattern here. An entity it's a concrete class with config code inside.
In large applications I've always encountered xml mapping files. I am looking at annotated entities only for small projects and with domain code that you want to keep at home.
Can you figure out some pattern here to be able to safely use annotation in entities without have to expose them outside their scope?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jothi Shankar Kumar wrote:I guess we need to think of some pattern that might help us keep the annotation and port the same entity to the client.

Hm, what do you mean? Annotations are hard-coded to classes. If you hard-coded something in classes, it will be there, it is a fact.

I don't like Annotations much. I think Annotations are suitable for artifacts that are supposed to be used with specific technology/platform such as Session Beans or MDBs.
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm not sure about what i'm gonna say but:
1. can't you share them as part of JAR file? such as only .class files will be used by other layers?
(the annotations are, somehow, visible in these files but not the mapping or semantics)
2. are you sure annotated and not annotated class are incompatible? i mean, maybe it's possible
to assign an annotated class to an non annotated?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic