JPA container and added properties.

I have the following situation: I have a table which use a jpacontianer as a data source. The jpa container uses an entity that has an data representation which is unsuitable to render with the default type in the database. The field is a charatcer fields which contains either of 0, 1, or null. I would like to convert these values to ‘yes’ and ‘no’ respectively.

The traditional way of doing this would be to define a table with an added pseudo property which is genertaed dynamically from the current container item. This is nomally achieved by;

tblFileList.addContainerProperty   ("ZIP", String.class, null);
tblFileList.addGeneratedColumn     ("ZIP", new FieldGeneratorIsZipArchive ());

My problem is that addContainerProperty would, indeed attempt to add the property to the underlying jpa container which is disallowed with the current incarnation of the jpa container (understandably so). What would be a suitable way forward in this case, in order to do a clean implementation? One way would possibly be to change the domain layer supplying the raw data, bu frankly that would just render me more problems in many other aspect, so I would like to view this as a pure gui problem (which it, in my humble opinion should be). Any suggestion form the ones with greater experience than mine on this issue?

  1. You could fix the mapping in your Entity using a Converter javax.persistence.AttributeConverter.
  2. Display the value in Tables using a ColumnGenerator with the same name as your property in the Item. ( ei dont add property to the Container, simply add ColumnGenerator to the Table… )

I am in the process of testing number two. I wasnt aware of the attributeconverter, thanks a lot for the tip! WIll take a peek!