Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Created June 7, 2018 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamBien/bfa3a444b6af3316e772f8eaf133f1cb to your computer and use it in GitHub Desktop.
Save AdamBien/bfa3a444b6af3316e772f8eaf133f1cb to your computer and use it in GitHub Desktop.
52ndAirhacksQ&A.md
@jpollard-github
Copy link

Hi Adam,

First thank you very much for your blog, books, and web-based courses. I am a recent Java convert after 15 years of Microsoft development, and your perspective on Java EE has been refreshing and enlightening. I switched to Java mainly because of standards and the richer ecosystem and history.

I have three higher level questions for you:

  • Are you planning to be involved with any of the specifications for Jakarta EE? I notice that you've been very involved in the past, and I've seen some of your comments in the new mailing lists. As someone new to the Java/JEE ecosystem, I'm curious what you think?

  • At the end of the green book, you present SOA and Domain Driven Design as two valid approaches in Java EE with ECB. I recently used ECB in a Java project (no Java EE, it's meant as a JAR for clients to consume). It was easy and straightforward, and I definitely used the SOA approach. Do you find yourself using the SOA approach or DDD approach more often with clients, or do you have any new thoughts on these approaches?

  • Do you have any recommendations on being a successful consultant with Java EE (or in general)? You have built up a great reputation over the years, and you continue to do so much for the community (like answering these questions and your courses). It's inspirational.

Thank you!
Jason Pollard
Charlotte, NC, USA

@kullmanp
Copy link

Hi Adam,
I have two questions regarding read-only validation calls in a JEE application with a REST api and JPA as persistence framework.

  • A call in a validation service should not make any persistent changes - it should just report validation messages. How can we make sure that changed entities are not flushed to the database? Use setRollbackOnly() in the method that starts the transaction? (This could also be done using an interceptor.)
  • What's the best REST-style for this kind of call? Say, I want to validate some order data that I normally would persist using PUT /orders/1234. Using a query param like validateOnly=true? Or use a POST to a different uri like /orders/validation?

@gbourant
Copy link

Hello Adam,

Let's say that you are using JAX-RS and you return a Person entity that has a relation with a country.

@Entity
class Person {
    private Long id;
    private String name;
    private Country country;
}

@Entity
class Country {
    private Long id;
    private String name;
}

When i make a GET request on person entity i want to get person's details and only the country ID.
Also on POST requests i want to convert the country ID to the country POJO (country must be received from database).

  1. I would like to hear how you would approach this problem.
  2. Since i'm using Java EE 8 i tried using JSON-B (JSR 367) to achieve the functionality described above.
    2.1) What's the proper way to inject entity manager on a class that implements the JsonbDeserializer ?
    2.2) Is it possible to make a class that implements the JsonbDeserializer using generics so i wouldn't have to implement JsonbDeserializer for each entity type.

Thank you.

@rieckpil
Copy link

rieckpil commented Jun 30, 2018

Hi Adam,

I have three questions for the upcoming airhacks show:

  1. How do migrate your database schema with Flyway? Do you use the Java/Maven or CLI approach?

What do you think about the following solution (JavaEE 8, OpenLiberty 18.0.0.2, Flyway 5.0.7)?

@Startup
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Singleton
public class FlywayMigration {

    private final Logger log = Logger.getLogger(this.getClass().getName());

    @Resource(lookup = "jdbc/sample")
    DataSource dataSource;

    @PostConstruct
    private void onStartup() {

        if (dataSource == null) {
            log.severe("no datasource found to execute the db migrations!");
            throw new RuntimeException(
                    "no datasource found to execute the db migrations!");
        }

        Flyway flyway = new Flyway();
        flyway.setDataSource(dataSource);
        for (MigrationInfo i : flyway.info().all()) {
            log.info("migrate task: " + i.getVersion() + " : "
                    + i.getDescription() + " from file: " + i.getScript());
        }
        flyway.migrate();

    }
}

And what's your Flyway strategy in enterprise projects for the SQL scripts? Do you create a single SQL script for every change during the Sprint or do you collect all changes during one sprint/cycle and squash them into one single SQL script, so that /db/migration won't grow that much?

  1. What are the three most important books about Programming/Software Design/Java every developer should read in your opinion?

  2. If you could give your 20-year-old self three lessons for your Developer career, what would it be?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment