Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ljnelson's full-sized avatar
🙃

Laird Nelson ljnelson

🙃
View GitHub Profile
@ljnelson
ljnelson / Permutations.java
Created October 17, 2021 20:54
Generating permutations
// I have been programming Java since 1996 at both the application and systems level.
// This seemingly elementary problem that I would fail on any junior-level interview
// gave me absolute fits. I wanted to capture it here for the benefit of other
// dullards like me. You are not alone.
//
// Suppose you have some number of arrays (let's say 2). Like so:
//
// final Object[] o0 = new Object[] { String.class, Number.class };
// final Object[] o1 = new Object[] { Object.class };
//
@ljnelson
ljnelson / ByteBuddyProxying.java
Last active December 21, 2020 18:27
A recipe for sketching out ByteBuddy proxy objects
import net.bytebuddy.description.modifier.Visibility;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.FieldAccessor;
import net.bytebuddy.implementation.MethodCall;
import static net.bytebuddy.implementation.MethodCall.invoke;
import static net.bytebuddy.matcher.ElementMatchers.named;
.level=INFO
handlers=io.helidon.common.HelidonConsoleHandler
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
com.zaxxer.hikari.level=INFO
h2database.level=WARNING
io.netty.level=INFO
org.eclipse.persistence.level=FINE
org.glassfish.jersey.server.level=CONFIG
@PersistenceContext
private EntityManager em;
@Dependent
public class ExampleResource {
// rest of class follows
}
import javax.enterprise.context.Dependent;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.transaction.Transactional;
import javax.ws.rs.PathParam;
<plugin>
<groupId>com.ethlo.persistence.tools</groupId>
<artifactId>eclipselink-maven-plugin</artifactId>
<version>2.7.1.1</version>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
package io.helidon.example.jpa;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="greeting" transaction-type="JTA">
<description>A persistence unit for the greeting example.</description>
<jta-data-source>greetingDataSource</jta-data-source>
<class>io.helidon.example.jpa.Greeting</class>