sebastiandaschner news


tuesday, october 17, 2017

Hello from Munich. Hard to believe, but I’m now a few days at home, after all the last travelings. But not too long, tomorrow I’ll be off to Basel, for the BaselOne conference! After I shortly visited that city as part of the “Road to BaselOne”, I’m now happy to come back for the actual conference.

The last days, I gave some more client workshops about Docker, Kubernetes and OpenShift. I also finally had the chance to update my offered workshops on my website. Go have a look if you like.

As promised the recording of the JavaOne community keynote is available! The recording remembers me how much fun it was and it’s interesting to see the show from the other side of the room :-)

And also we (finally) announced the jSpirit unconference. This is a new Java unconference held in the Bavarian alps in early 2018 at Europe’s modernest distillery! The motto is Spirits, Ski & Java. We will have two days of unconference with hopefully interesting and inspiring discussions and for those who like another two days of Skiing. Of course there will be a lot of “Spirits” as well — again, it’s held at a distillery :-) — and a beautiful and hopefully snowy atmosphere. Btw, if you — like myself — don’t care about alcohol or Skiing, there will be plenty of alternative activities; I heard there is the possibility to paraglide over the Baravian winter landscape! So I highly advise you to check out the website.

Anyway, now back to more serious topics. The EE4J discussion on the Eclipse mailing list are more than active — it’s actually challenging to keep track. Which is a good thing; I’m looking forward for the next level of enterprise Java.

On this Thursday I’ll be speaking at BaselOne about the Command Query Responsibility Segregation principle with Java. Next week I’ll travel to the city of Düsseldorf for the JCON conference. And then I’ll immediately fly back home to back in time for the 24-hour virtual Java conference: vJUG24. So interesting and packed days ahead!

 

What’s new

 

CDI support in JPA 2.2 attribute converters

JPA 2.2 finally added support to inject managed beans into attribute converters using CDI’s @Inject. This increases the use and number of scenarios of custom attribute converters.

The following car specifies a manufacturer that will be converted via custom logic:

@Entity
@Table(name = "cars")
public class Car {

    @Id
    private long id;

    @Convert(converter = ManufacturerConverter.class)
    private Manufacturer manufacturer;

    private EngineType engineType;

    // ...
}

Since JPA 2.2 converter classes like the following can now inject managed beans.

@Converter
public class ManufacturerConverter implements AttributeConverter<Manufacturer, String> {

    @Inject
    ManufacturerStore manufacturerStore;

    @Override
    public String convertToDatabaseColumn(Manufacturer attribute) {
        return attribute.getManufacturerCode();
    }

    @Override
    public Manufacturer convertToEntityAttribute(String code) {
        return manufacturerStore.retrieveManufacturer(code);
    }
}

Similar to many other standards within Java EE, better CDI integration encourages reuse of Java EE components.

 

Thanks a lot for reading and see you next time!

 

Did you like the content? You can subscribe to the newsletter for free:

All opinions are my own and do not reflect those of my employer or colleagues.