Skip to content

Instantly share code, notes, and snippets.

View sebersole's full-sized avatar

Steve Ebersole sebersole

View GitHub Profile
@sebersole
sebersole / TheTest.java
Created February 8, 2019 16:15
Test illustration isolation
import static org.hibernate.testing.transaction.TransactionUtil2.inSession;
import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;
class TheTest {
@Test
public void testIsolation() {
// open the "writing Session"
inSession(
getTheSessionFactory(),
writingSession -> {
public abstract class BaseSqmToSqlAstConverter {
...
@Override
public ComparisonPredicate visitComparisonPredicate(SqmComparisonPredicate predicate) {
class TypeResolver implements BiFunction<SqmExpression,Supplier<ExpressableType<?>>,ExpressableType<?>> {
private final SqmExpression otherSide;
private TypeResolver(SqmExpression otherSide) {
this.otherSide = otherSide;
public abstract class AbstractSelectCriteria<T, C extends SelectCriteriaImplementor<T>>
extends AbstractNode
implements SelectCriteriaImplementor<T> {
@Override
public C distinct(boolean distinct) {
...
return this;
}
@sebersole
sebersole / customizations.adoc
Created November 29, 2018 13:19
Type System Customizations

Type System Customization

Hibernate’s "type system" can be customized in a number of ways depending on the nature of the type (basic, entity, etc).

Note

Customization of the Hibernate type system is considered an integration activity, as opposed to an application activity. As of 6.0, all of Hibernate’s type system is considered "incubating"

org.hibernate.graph.EntityGraphsTest > testBasicMerge FAILED
java.lang.NullPointerException at EntityGraphsTest.java:163
org.hibernate.graph.EntityGraphsTest > testDifferentBasicsEqual1 FAILED
java.lang.NullPointerException at EntityGraphsTest.java:44
org.hibernate.graph.EntityGraphsTest > testDifferentBasicsEqual2 FAILED
java.lang.NullPointerException at EntityGraphsTest.java:51
org.hibernate.graph.EntityGraphsTest > testDifferentComplexGraphsEqual FAILED
@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;
@sebersole
sebersole / CollectionSemantics.java
Created June 10, 2018 14:25
CollectionSemantics contract
public interface CollectionSemantics<C> {
/**
* Get the classification of collections described by this semantic
*/
CollectionClassification getCollectionClassification();
C instantiateRaw(int anticipatedSize);
Iterator getElementIterator(C rawCollection);
{
"toolVersion": "1.0.0-SNAPSHOT",
"baseVersion": "5.0.0.Final",
"checkVersion": "5.3.0.CR2",
"generated": "2018-05-04T18:54:50.107Z",
"incubating": {
"classes": [
{
"name": "org.hibernate.annotations.LazyGroup"
},
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Internal
Class org.hibernate.action.internal.AbstractEntityInsertAction
Class org.hibernate.action.internal.BulkOperationCleanupAction
Class org.hibernate.action.internal.CollectionAction
...
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Incubating
@Test
public void testIt() {
JavaTypeDescriptorRegistry.INSTANCE.addDescriptor( new MyCustomJavaDescriptor(...) );
new TypeConfiguration().getJavaDescriptorRegistry().getDescriptor( MyCustom.class ) ...
}