Skip to content

Instantly share code, notes, and snippets.

View sebersole's full-sized avatar

Steve Ebersole sebersole

View GitHub Profile
@sebersole
sebersole / gist:f2c000c50cce19ab01c50a6a8fa1640b
Created April 29, 2019 22:17 — forked from gbadner/gist:a9cb2b5547aeddf96c36cb6108e72403
Cases for HibernateProxy with enhancement
Enhanced Enhanced
allow_enhancement_as_proxy=true allow_enhancement_as_proxy=false Non-enhanced
Session#load: returns uninitialized, enhanced entity return enhanced entity that return entity
(entity/proxy (per HHH-11147) implements HibernateProxy that implements
not in PC HibernateProxy
yet)
LazyToOne:
@sebersole
sebersole / MultipleInitiatorTest.java
Last active September 21, 2018 14:33 — forked from scottmarlow/MultipleInitiatorTest.java
MultipleInitiatorTest
package org.hibernate.service;
import java.util.Map;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.internal.RegionFactoryInitiator;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.spi.ServiceContributor;
task generateEnversStaticMetamodel(type: JavaCompile) {
source = sourceSets.main.java
include "org/hibernate/envers/**"
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.compileClasspath
options.compilerArgs = [
"-proc:only",
"-processor",
"org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor"
]
destinationDir = new File( "${projectDir}/src/main/java" )
@sebersole
sebersole / BytecodeInterceptorImpl.java
Last active November 13, 2015 16:36 — forked from barreiro/Experiment1.java
Discussion regarding design changes in bytecode enhancement
public class BytecodeInterceptorImpl implements BytecodeInterceptor {
private final Object interceptedEntity;
// "delegates" for the various interception capabilities.
private LazyAttributeInterceptionHandler lazyAttributeHandler;
private DirtinessTrackingInterceptionHandler dirtinessHandler;
private AssociationManagementInterceptionHandler associationHandler;
...
public BytecodeInterceptorImpl(Object interceptedEntity) {
package com.liberologico.cloudesire.cmw.test.unit;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
@Override
public void doCreation(Metadata metadata, boolean createNamespaces, Dialect dialect, Target... targets)
throws SchemaManagementException {
boolean tryToCreateCatalogs = false;
boolean tryToCreateSchemas = false;
if ( createNamespaces ) {
if ( dialect.canCreateCatalog() ) {
tryToCreateCatalogs = true;
}
MetadataSources sources = new MetadataSources(...)
...
.addAnnotatedClasses( Item.class );
.buildMetadata();
MetadataSources sources = new MetadataSources(...)
...
.addAnnotatedClasses( Item.class );
.usingContext()
.setNamingStrategy( new MyNamingStrategy() )