Skip to content

Instantly share code, notes, and snippets.

View sebersole's full-sized avatar

Steve Ebersole sebersole

View GitHub Profile
public interface Integrator {
public void prepareServices(ServiceRegistryBuilder serviceRegistryBuilder);
public void prepareMetadata(MetadataImplementor metadata);
public void integrate(
MetadataImplementor metadata,
SessionFactoryImplementor sessionFactory,
SessionFactoryServiceRegistry serviceRegistry);
interface EntityLoadAccess<T> {
public T getReference(Object key);
public T getReference(Object key, LockOptions lockOptions);
public T load(Object key);
public T load(Object key, LockOptions lockOptions);
}
session.entityLoadAccess( SomeEntity.class ).byId().getReference( 123 )
interface EntityLoadAccess<T> {
public T getReferenceById(Object id);
public T getReferenceById(Object id, LockOptions lockOptions);
public T getReferenceByNaturalKey(Object key);
public T getReferenceByNaturalKey(Object key, LockOptions lockOptions);
public T loadById(Object id);
public T loadById(Object id, LockOptions lockOptions);
public T loadByNaturalKey(Object key);
public T loadByNaturalKey(Object key, LockOptions lockOptions);
}
/**
* Specifically access by id
*/
interface IdentifierLoadAccess<T> {
public IdentifierLoadAccess<T> with(LockOptions lockOptions);
public T getReference(Object id);
public T load(Object id);
}
@sebersole
sebersole / JdbcCoordinator.java
Created November 28, 2011 22:08
HHH-6780 - Wrong Query timeout calculation
public interface JdbcCoordinator extends Serializable {
/**
* Set the effective transaction timeout period for the current transaction, in seconds.
*
* NOTE : Same signature, just added javadocs...
*/
public void setTransactionTimeOut(int seconds);
/**
* Retrieve the amount of time, in seconds, still remaining before transaction timeout occurs.
try {
try {
PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
try {
getLockable().getIdentifierType().nullSafeSet( st, id, 1, session );
if ( getLockable().isVersioned() ) {
getLockable().getVersionType().nullSafeSet(
st,
version,
getLockable().getIdentifierType().getColumnSpan( factory ) + 1,
logicalExpression
: logicalOrExpression
;
logicalOrExpression
: logicalAndExpression ( or^ logicalAndExpression )*
;
logicalAndExpression
: negatedExpression ( and^ negatedExpression )*
The Hibernate team is pleased to announce the release of Hibernate Core 4.0.0.Final. A lot of time and effort from many people went into this release, so thank you everyone involved!
++ What's new?
A lot of things; too many to list here. But here is a list of the major improvements done in 4.0:
# Initial multi-tenancy support. See [=>http://in.relation.to/Bloggers/HibernateAndMultitenancyWebinar] and [=>http://in.relation.to/Bloggers/MultitenancyInHibernate] for more information.
# Introduction of ServiceRegistry. This is a major change in how Hibernate builds and manages "services". See the information in the *Hibernate Developer Guide*.
# Clean up of Session opening from SessionFactory
# Improved integration via org.hibernate.integrator.spi.Integrator and auto discovery
@sebersole
sebersole / orm2.xml
Last active December 15, 2015 07:28
validation problem
Caused by: javax.xml.stream.XMLStreamException: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 10; cvc-complex-type.2.4.a: Invalid content was found starting with element 'entity-mappings'. One of '{"http://java.sun.com/xml/ns/persistence/orm":description, "http://java.sun.com/xml/ns/persistence/orm":persistence-unit-metadata, "http://java.sun.com/xml/ns/persistence/orm":package, "http://java.sun.com/xml/ns/persistence/orm":schema, "http://java.sun.com/xml/ns/persistence/orm":catalog, "http://java.sun.com/xml/ns/persistence/orm":access, "http://java.sun.com/xml/ns/persistence/orm":sequence-generator, "http://java.sun.com/xml/ns/persistence/orm":table-generator, "http://java.sun.com/xml/ns/persistence/orm":named-query, "http://java.sun.com/xml/ns/persistence/orm":named-native-query, "http://java.sun.com/xml/ns/persistence/orm":sql-result-set-mapping, "http://java.sun.com/xml/ns/persistence/orm":mapped-superclass, "http://java.sun.com/xml/ns/persistence/orm":entity, "http://java.sun.com/xml/ns/pers
public class NamedQueryRepository {
/**
* Defines allowable policies for handling attempts to mutate a repository after initialization
*/
public static enum MutationPolicy {
/**
* Allow attempts to mutate the repository after it has been initialized.
*/
ALLOW,
/**