Skip to content

Instantly share code, notes, and snippets.

View torstenwerner's full-sized avatar

Torsten Werner torstenwerner

View GitHub Profile
@torstenwerner
torstenwerner / oracle-update-returning.sql
Last active July 19, 2020 10:05
Oracle jdbc update with returning clause
declare
o0 dbms_sql.varchar2_table;
o1 dbms_sql.varchar2_table;
c0 sys_refcursor;
c1 sys_refcursor;
begin
update "C##TEST"."AUTHOR"
set "C##TEST"."AUTHOR"."FIRST_NAME" = ?
where "C##TEST"."AUTHOR"."LAST_NAME" = ?
returning "C##TEST"."AUTHOR"."FIRST_NAME", "C##TEST"."AUTHOR"."LAST_NAME" bulk collect into o0, o1;
at ...Delete...ServiceBeanImpl.delete...(Delete...ServiceBeanImpl.java:50)
at sun.reflect.GeneratedMethodAccessor1257.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:90)
at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
@torstenwerner
torstenwerner / Scratch.java
Created April 3, 2018 15:46
sample jpa annotations
import javax.persistence.*;
@Entity
class Scratch {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
String a;
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
static void enableMetroDumps() {
// https://metro.java.net/guide/ch02.html#logging
// dumps encrypted transport messages
System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
// dumps unencrypted/decrypted message before/after security tube's processing
System.setProperty("com.sun.xml.wss.provider.wsit.SecurityTubeFactory.dump", "true");
System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "100000");
}
SELECT a1.*
FROM attribute a1
WHERE a1.Name = 'referencenumber' AND a1.value LIKE '%A123%';
SELECT a0.*
FROM attribute a0
WHERE a0.userid IN (
SELECT a1.userid
FROM attribute a1
WHERE a1.Name = 'referencenumber' AND a1.value LIKE '%A123%');
/**
* Simple Xml validation using the joox library.
*/
@Grapes(
@Grab(group = 'org.jooq', module = 'joox', version = '1.4.0')
)
import static org.joox.JOOX.*
def document = $(new File('instance-xs11.xml'))
/**
* Simple schematron executer for a schema which is embedded into a Xml schema.
*/
import javax.xml.transform.TransformerFactory
import javax.xml.transform.stream.StreamResult
import javax.xml.transform.stream.StreamSource
def schemaName = 'choice-schematron.xsd'
def instanceName = 'instance-schematron.xml'
/**
* Xsd 1.1 validation with a pimped xerces2 jar.
*/
@Grapes(
@Grab(group = 'com.rackspace.apache', module = 'xerces2-xsd11', version = '2.11.2')
)
import javax.xml.transform.stream.StreamSource
import javax.xml.validation.SchemaFactory
@torstenwerner
torstenwerner / dynamic.groovy
Created January 11, 2017 13:30
invoke java method dynamically in groovy code
def iClass = 'java.lang.Integer' as Class
assert iClass.newInstance(26) == 26
def greeting = 'Hello'
def method = 'length'
assert greeting."$method"() == 5
configurations.all {
resolutionStrategy {
eachDependency {
DependencyResolveDetails details ->
// Bouncy castle is unfriendly to the maven resolution process. Override the dependencies here.
if (details.requested.name.startsWith('bcprov-')) {
details.useTarget 'org.bouncycastle:bcprov-jdk15on:1.46'
}
if (details.requested.name.startsWith('bcmail-')) {
details.useTarget 'org.bouncycastle:bcmail-jdk15on:1.46'