-
1. Re: Common superclass to all entities?
phon Sep 28, 2005 2:14 AM (in response to phon)i'm still struggling with the "EmbeddableSuperclass classes may only have basic attributes" message. Also can i create a hierarchy of EmbeddableSuperclasses ?
What i want is something like this :
BaseEntity (abstract with audit fields and id information)
|
----> MultiLanguageEntity (asbtract with descriptions in multiple languages)
|
------> ActualEntity
i can't get it working with the id field on the BaseEntity. It works though when i specify ID fields on all the actualentities, but i can't really work with BaseEntities in polymorphic calls because they don't know getId()
anyone has a solution for this or am i trying something completely stupid and is there another better way? -
2. Re: Common superclass to all entities?
epbernard Oct 3, 2005 12:16 PM (in response to phon)This is not supported yet.
-
3. Re: Common superclass to all entities?
perfectionist Oct 4, 2005 5:38 PM (in response to phon)I used this and it seems to work - I have three fields I want in every Entity class.
23 @EmbeddableSuperclass(access=AccessType.PROPERTY) 24 public abstract class PObject implements Serializable{ 25 26 private int id; 27 private User updateUser; 28 private Timestamp updateTimestamp; 29 30 public Timestamp getUpdateTimestamp() { 31 return updateTimestamp; 32 } 33 public void setUpdateTimestamp(Timestamp updateTimestamp) { 34 this.updateTimestamp = updateTimestamp; 35 } 36 37 @ManyToOne 38 public User getUpdateUser() { 39 return updateUser; 40 } 41 public void setUpdateUser(User updateUser) { 42 this.updateUser = updateUser; 43 } 44 45 @Id(generate = GeneratorType.AUTO) 46 public int getId() { 47 return id; 48 } 49 public void setId(int id) { 50 this.id = id; 51 } 52 53 54 }
Every entity class extends this class. Hope this helps. -
4. Re: Common superclass to all entities?
phon Oct 5, 2005 3:14 AM (in response to phon)indeed, i have a similar setup and it also works here
i only seem to experience problems when gettin the objects back from the database, some fields in from the EmbeddableSuperclass are set (in my case the id is in the superclass, and it definately gets set) but others are not (the createdDate is in the database, but the property doesn't get set when i query the database.
do you experience the same problem ? -
5. Re: Common superclass to all entities?
pabry Oct 5, 2005 11:29 AM (in response to phon)I have a similar problem. However, It worked for me in 4.0.3RC2, but now I'm having problems in 4.0.3.
You can se my problems in this thread: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=70401