openxava
Blog

March 27, 2019

OpenXava 6.1 released

Traditionally in each new major version of OpenXava we upgrade all the libraries and drop support for old versions of servers, Java, etc. However, for version 6 we delivered a user-centric version and left out the traditional libraries upgrading. Therefore, we have done this upgrading for 6.1. So, version 6.1 is really a version 6.0 part 2. Mainly this new version drops Java 6 (and 7) support. This was indispensable to upgrade the third-party libraries given currently there is no libraries with Java 6 support. This means the we no longer support WebSphere 8, but also means the we can enjoy new useful features such as repeatable annotations, LocalDate or JPA 2.2.

We invite you to download it and upgrade your OpenXava applications. Look at the migration instructions.

Download OpenXava 6.1

Java Persistence API 2.2 support

JPA 2.2 supports repeating annotations; injection into attribute converters; support for mapping of the java.time.LocalDate, java.time.LocalTime, java.time.LocalDateTime, java.time.OffsetTime, and java.time.OffsetDateTime types; and methods to retrieve the results of Query and TypedQuery as streams. 
The funniest thing of the new JPA is that you can use streams in queries. For example, for a query like this:

TypedQuery<Invoice> q = XPersistence.getManager()
    .createQuery("SELECT i FROM Invoice i", Invoice.class);
If you want to get the sum of the amounts of all the invoices, using the traditional JPA you would write:
List<Invoice> invoices = q.getResultList();
BigDecimal totalWithLoop = BigDecimal.ZERO;
for (Invoice invoice: invoices) {
	totalWithLoop = totalWithLoop
        .add(invoice.getAmountsSum());
}
From now on, you can just write:
BigDecimal totalWithStream = q.getResultStream()
    .map(Invoice::getAmountsSum)
    .reduce(BigDecimal.ZERO, BigDecimal::add);
Optionally, of course. Only if you love this new Java 8 world without loops and ifs.

Also, the use of repeatable annotations for JPA makes the code a bit cleaner. For example, you no longer need to use @JoinColumns for mapping a foreign composite key, just use several @JoinColumn in this way:
@ManyToOne
@JoinColumn(name="PROFILE_APPLICATION_CODE", 
    referencedColumnName="APPLICATION_CODE")
@JoinColumn(name="PROFILE_CODE",
    referencedColumnName="CODE")
private Profile profile;
 

Repeatable annotations

The above @JoinColumn example is a sample of a very useful new feature of Java 8, the repeatable annotations. And, of course, we have made all the OpenXava annotations suceptible to be repeatable, repeatable.
So, if you want to define several views for an entity, you don't need to use @Views anymore:

@Entity
@View( members=
    "number;" +
    "type;" +
    "name, Customer.changeNameLabel();" +
    "photo;" +
    "telephone, email;" +
    "website;" +
    "address;" +
    "city;" +
    "seller [" +
    "    seller; " +
    "    relationWithSeller;" +
    "]" +
    "alternateSeller;"  +
    "deliveryPlaces;" +
    "remarks"
)
@View( name="Simple", members=
    "number;" +
    "type;" +
    "name, Customer.changeNameLabel(ALWAYS);" +
    "photo;" +
    "address;"
)
@View( name="SimpleWithCity", 
    extendsView="Simple", 
    members= "; city")
public class Customer {
Also available for @Tab, all annotations with forViews, and many more annotations. Another example:
@ManyToOne(fetch=FetchType.LAZY)
@DescriptionsList(
    condition="${thing.number} = ?", 
    depends="this.usedTo")
@DescriptionsList(
    forViews="Ordinary2", 
    condition="${number} < 2",
    forTabs="Color2")
private CharacteristicThing characteristicThing;

Note as we don't use @DescriptionsLists to wrap the two @DescriptionsList.

LocalDate from Java 8

The java.util.Date of Java is a hoax, because it's not a date, it's a moment in time, including milliseconds. But because it is called Date, and we have not alternative, we use it as a date, creating a lot of confusion and problems, such as when a date changes when the object moves from a server to another with a different timezone, for example. Or when two dates are not equal, even if they are of the same day. Since Java 8 we have a new type, LocalDate, that is a real date, that is just a day, month and year. In most cases the type we should use in our business applications should be LocalDate.

OpenXava 6.1 supports java.time.LocalDate, so you can write:

public class Invoice {
    
    ...

    @Required
    @DefaultValueCalculator(CurrentLocalDateCalculator.class)
    private java.time.LocalDate date;
Note that we use the new CurrentLocalDateCalculator as default calculator. LocalDate is mapped to a DATE type in the database, just as the traditional java.util.Date

Libraries upgrades

We have upgraded a lot of third party libraries:

  • JasperReports upgraded to 6.7.0.
  • Hibernate upgraded to 5.3.9.
  • Hibernate Envers upgraded to 5.3.9.        
  • Hibernate Commons Annotations upgraded to 5.0.4.
  • Hibernate Validator upgraded to 6.0.15.
  • Commons Validator upgraded to 1.6.
  • Commons FileUpload library upgraded to 1.4.
  • JSoup upgraded to 1.11.3.
  • Groovy upgraded to 2.4.5. 
  • JSTL Apache standard implementation upgraded to 1.2.5. 
  • JavaMail upgraded to 1.6.3.
  • Upgrade of PDF/Excel libraries: itext-2.1.7, poi 3.15, poi-ooxml 3.15, poi-ooxml-schemas 3.15.  
  • HtmlUnit upgraded to 2.32.
  • Upgrade of beans and collections libraries: commons-beanutils 1.9.3, commons-collections 3.2.2. 
  • Upgrade of common libraries: commons-codec 1.10, commons-io 2.6, commons-lang3 3.8, dom4j 2.1.1.
  • Upgrade of class management libraries: classmate 1.3.4, jandex 2.0.5, javassist 3.23.1, 
  • Upgrade of logging libraries: commons-logging 1.2, jboss-logging-3.3.2.Final.
  • Upgrade pre-Java 9 libraries: javax.activation 1.2.0, jaxb-api-2.3.1.

Other improvements

We have done a lot of improvements in other areas:

  • Bean Validation 2.0 support.
  • Tooltip for module description in left menu when the module description doesn't match the name.
  • Parsing of filter arguments in list is done using the editor formatter for the type.
  • New method getCurrentIP() in Users class.
  • 25% of performance improvement in jUnit tests.
  • Added new utility libraries: commons-text 1.4, commons-collections4 4.3.
  • Workspace in distribution upgraded to Eclipse 2019-03, though it still works with Neon (4.6).
  • Removed LayoutParser and LayoutPainter code introduced in v5.0, disabled since v5.5. 
  • Some new common use labels to be used in applications.

Bug fixes

Though this is not a maintenance version we have done some fixes:

  • Fix: @Trees annotation, used to wrap several @Tree, does not work.
  • Fix: Stacktrace in log when showing collection totals. 
  • Fix: Confusing stacktrace on starting any jUnit test. 
  • Fix: When the user removes a column in the list a narrow empty column remains.
  • Fix: Some missing images in Getting Started guide in Spanish.
  • Fix: Some misspellings in English messages.    
  • Fix: Charts are frozen when the list has a lot of records.
  • Fix: On page navigation in collections with @OnSelectElementAction selected elements are lost. 
Download OpenXava 6.1

blog comments powered by Disqus