Wednesday, March 31, 2021

sql logging for jsf application in netbeans

To enable SQL logging to the netbeans console for a JSF application running in Payara with EclipseLink, add the following properties to the persistence.xml file: 
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
More information here and here.

On a related note, logging can also be enabled directly in mysql, if that's the underlying database.  Here are some notes about doing that:

log in to mysql as root:
-> use mysql; 
-> SET global log_output = 'table'; 
-> SET GLOBAL general_log = 1;
then you can see the logged statements using:
select * from general_log;

or count the number of sql statements:
select count(*) from general_log; 
and clean it up with:
truncate general_log; 

Friday, March 12, 2021

java method reference

I can never remember the syntax for passing a method reference in Java, so I'm pasting a note about it here.  Here is a decent link explaining the idea.

Here is a method that accepts a method reference as a parameter, and calls that method in its body:

protected ItemDomainEntity findByPath_(String path, Function<ItemDomainEntity, ItemDomainEntity> parentGetterMethod) {

    ItemDomainEntity candidateParent = parentGetterMethod.apply(candidateItem);


And then an example of calling that method:

findByPath_(path, ItemDomainMachineDesign::getParentMachineDesign);