When I say "non-persistent method" I'm referring to entity methods which don't 
have persistable attributes associated with them (i.e. logic only).  There is 
surely a better way of describing it.  These methods are actually related to 
the current state of a PERSISTED entity, so an empty pojo is of little use to 
them.  It's really semantic state-sensitive logic.  To explain, consider my 
other (slightly confusing) post, to which you graciously responded.

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=98505

I have an entity, which I have loaded from the EntityManager.  It has an 
Integer attribute named status.  Status can be 0 or 1.  On the client I want to 
display "OK" for 0 and "BAD" for 1.

I'm still developing the POC for the solution but it's much simpler than I 
thought.  I just put the "non-persistent methods" in the base class of the 
entity.  Here is a contrived example:

public abstract class StatusBase {
  |     public abstract Integer getStatus();
  |     
  |     public String getStatusText(){
  |         if(getStatus().intValue() == 0){
  |             return "OK";
  |         }else{
  |             return "BAD";
  |         }
  |     }    
  | }
  | 


@Entity
  | @Name("statusExample")
  | @Table(name = "MY_TABLE")
  | public class Status extends StatusBase implements Serializable {
  |     public Integer status = null;
  | 
  |     @Column(name = "STATUS", length = 1, nullable = false)
  |     public abstract Integer getStatus(){
  |         return this.status;
  |     }
  | }
  | 

This way I can still interact with the entity to get the non-persistent value 
for the view.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3998403#3998403

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3998403
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to