Skip to content

Instantly share code, notes, and snippets.

@gbadner
gbadner / gist:9099683
Created February 19, 2014 19:28
Different types of Type
(11:26:53 AM) sebersole: i almost want to make it build the "domain model" first
(11:27:23 AM) sebersole: and use that to reference class names, attributes, etc
(11:27:34 AM) gbadner: +1
(11:28:03 AM) gbadner: I understand now why you had Type.getClassName() and getClassReference()
(11:29:00 AM) gbadner: it would be really nice if o.h.metamodel.spi.Type encapsulated HibernateTypeDescription
(11:29:15 AM) sebersole: it cant always
(11:29:30 AM) sebersole: especially in the case of composites
(11:29:56 AM) sebersole: think the distinction between Embeddable and Embedded
(11:30:13 AM) sebersole: Type would be the Embeddable
(11:30:28 AM) sebersole: HibernateTypeDescription would be the Embedded
public interface Mappings {
...
/**
* Get the current naming strategy.
*
* @return The current naming strategy.
*/
@deprecated
public NamingStrategy getNamingStrategy();
@gbadner
gbadner / gist:057dac7388205352765c
Last active August 29, 2015 14:06
Objects needing logical/physical names
Table names:
Primary table
Currently generated by: NamingStrategy.classToTableName(String className)
Input: LogicalPrimaryTableNameSource
Secondary table:
Element collection table name:
Inputs:
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java
index c6a2856..c10a5ee 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java
@@ -34,6 +34,7 @@ import org.hibernate.annotations.ColumnTransformers;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.Nullability;
+import org.hibernate.cfg.naming.ImplicitAttributeColumnNameSource;
import org.hibernate.internal.CoreMessageLogger;
@gbadner
gbadner / gist:9ab8f91d227470175f33
Created October 1, 2014 22:11
NamingStrategyDelegator/NamingStrategyDelegate (not good names; need to change...)
/**
* Provides access to the appropriate {@link NamingStrategyDelegate}.
*
* @author Gail Badner
*/
public interface NamingStrategyDelegator {
public void injectNamingStrategy(NamingStrategy namingStrategy);
/**
@gbadner
gbadner / gist:943347
Created April 26, 2011 22:37
Process for building SessionFactory
Build ServiceRegistry
---------------------
Map config = ...;
A) ServiceRegistry serviceRegistry =
new ServiceRegistryBuilder( config )
...
.buildServiceRegistry();
MetadataImpl constructor:
public MetadataImpl(MetadataSources metadataSources, ProcessingOrder preferredProcessingOrder) {
this.serviceRegistry = metadataSources.getServiceRegistry();
this.namingStrategy = metadataSources.getNamingStrategy();
final ArrayList<String> processedEntityNames = new ArrayList<String>();
if ( preferredProcessingOrder == ProcessingOrder.HBM_FIRST ) {
applyHibernateMappings( metadataSources, processedEntityNames );
applyAnnotationMappings( metadataSources, processedEntityNames );
@gbadner
gbadner / gist:948758
Created April 29, 2011 18:22
Metamodel tasks
1) MetadataSources -> Metadata -> SessionFactory process
[HHH-6107] - Metamodel dependence on ServiceRegistry (Steve: done)
[HHH-6138] - Implement addition of annotated classes and packages in MetadataSources (Steve: done)
[HHH-6141] - Develop scheme for ordered processing of MetadataSources sources (Steve: done)
A) for HBM XML
[HHH-2578] - redesign SessionFactory building (Steve: done)
[HHH-6145] - Create an "xml binding" service (Steve: open)
B) for EM
[HHH-6149] - Clean up EJB3Configuration (Steve: open)
[HHH-6159] - Determine best way to handle EntityManagerFactory building
@gbadner
gbadner / gist:974835
Created May 16, 2011 16:56
Entity/Attribute Binding
HHH-6227 will provide a way to update Entity/Attribute objects in EntityBinding/AttributeBinding objects
EntityBinding entityBinding =
new EntityBinding( name )
.initialize( new HbmEntityBindingState( getHibernateMappingBinder(), ... )
.initialize( new HbmEntityRelationalState( getHibernateMappingBinder(), ... );
entityBinding.setEntity( new Entity( name ) ) can be called immediately or later
@gbadner
gbadner / gist:981804
Created May 19, 2011 21:34
Clarification of Attribute/Value Bindings
In the new metamodel code, it appears that both "Attribute" and "Value" bindings are modelled using AttributeBinding. The places I've seen references to "Value" bindings (EntityIdentifier, Discriminator) don't necessarily have a domain representation.
I'm working on @IdClass, and this an example where the IdClass itself does not have a representation in the domain model.
I'd like to make some improvements.
NOTE: This uses POJO terminology; this applies to other entity modes as well.
EntityBinding knows about 3 different kinds of bindings: