Solved! I've seen a number of posts relating to this issue but none with
solutions...

In searching for how $JAVASSIST_READ_WRITE_HANDLER came into existence
we find:
http://www.docjar.com/html/api/org/hibernate/tool/instrument/javassist/FieldTransformer.java.html


There we can see the getter for "$JAVASSIST_READ_WRITE_HANDLER" is
actually "getFieldHandler" so the exclude parameter becomes:

    @Action(value = "list-clients", results = {
        @Result(type = "json", params = {
            "excludeProperties",
            "^list\\[.*\\]\\.fieldHandler\\..*"
        })
    })

And it all works... 

Just tested the shorter ".*\\.fieldHandler\\..*" and it works too, which
is much better because now there is one solution for all such
instrumented entities!  
 
On Tue, 2011-09-06 at 22:20 -0600, Ken McWilliams wrote:
> I have a JPA entity, which hibernate is proxying.  
> 
> The following action works as it explicitly states the properties to
> include, however what I would much rather do is use excludeProperties to
> remove the problematic property. The problem property when serialized
> causes a "Positioned Update not supported" exception.
> 
> The interesting thing is, all the properties on the entity class are
> persisted correctly if explicitly included.
> 
> Looking in the  the debugger shows there is a property called
> "$JAVASSIST_READ_WRITE_HANDLER" of type FieldInterceptorImpl which
> Hibernate/JPA adds to the entity. I'm pretty sure this is what is
> causing it to fail.
> 
> 
> I've tried the following: 
>     @Action(value = "list-clients", results = {
>         @Result(type = "json", params = {
>             "excludeProperties",
>             "list\\[.*\\]\\.\\$JAVASSIST_READ_WRITE_HANDLER.*"
>         })
>     })
> 
> but with no luck.  Following is my action and the entity class.
> 
>  
> 
> Here is my action (In a _working_ state):
> /////////////////////////////
> @ParentPackage("json-default")
> @Result(type = "json")
> public class ListTable extends ActionSupport {
> 
>     @EJB
>     private ClientService clientService;
>     private List list;
> 
>     @Action(value = "list-clients", results = {
>         @Result(type = "json", params = {
>             "includeProperties",
>             "list\\[.*\\]\\.name, list\\[.*\\]\\.id, list\\[.*\\]\
> \.timelogCollection\\..*" 
>         })
>     })
>     public String listClients() {
>         list = clientService.list();
>         return SUCCESS;
>     }
> 
>     public List getList() {
>         return list;
>     }
> }
> /////////////////////////////
> 
> Here is the entity:
> /////////////////////////////
> @Entity
> @Table(name = "client")
> @XmlRootElement
> @NamedQueries({
>     @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client
> c"),
>     @NamedQuery(name = "Client.findById", query = "SELECT c FROM Client
> c WHERE c.id = :id"),
>     @NamedQuery(name = "Client.findByName", query = "SELECT c FROM
> Client c WHERE c.name = :name")})
> public class Client implements Serializable {
>     private static final long serialVersionUID = 1L;
>     @Id
>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>     @Basic(optional = false)
>     @NotNull
>     @Column(name = "id")
>     private Integer id;
>     @Size(max = 45)
>     @Column(name = "name")
>     private String name;
>     @OneToMany(cascade = CascadeType.ALL, mappedBy = "clientId")
>     private Collection<Timelog> timelogCollection;
> 
>     public Client() {
>     }
> 
>     public Client(Integer id) {
>         this.id = id;
>     }
> 
>     public Integer getId() {
>         return id;
>     }
> 
>     public void setId(Integer id) {
>         this.id = id;
>     }
> 
>     public String getName() {
>         return name;
>     }
> 
>     public void setName(String name) {
>         this.name = name;
>     }
> 
>     @XmlTransient
>     public Collection<Timelog> getTimelogCollection() {
>         return timelogCollection;
>     }
> 
>     public void setTimelogCollection(Collection<Timelog>
> timelogCollection) {
>         this.timelogCollection = timelogCollection;
>     }
> 
>     @Override
>     public int hashCode() {
>         int hash = 0;
>         hash += (id != null ? id.hashCode() : 0);
>         return hash;
>     }
> 
>     @Override
>     public boolean equals(Object object) {
>         // TODO: Warning - this method won't work in the case the id
> fields are not set
>         if (!(object instanceof Client)) {
>             return false;
>         }
>         Client other = (Client) object;
>         if ((this.id == null && other.id != null) || (this.id != null
> && !this.id.equals(other.id))) {
>             return false;
>         }
>         return true;
>     }
> 
>     @Override
>     public String toString() {
>         return "com.aerose.kentimekeeper.db.Client[ id=" + id + " ]";
>     }
>     
> }
> /////////////////////////////
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to