Java 类org.hibernate.AssertionFailure 实例源码
项目:lams
文件:Configuration.java
public void addAttributeConverter(AttributeConverterDefinition definition) {
if ( attributeConverterDefinitionsByClass == null ) {
attributeConverterDefinitionsByClass = new ConcurrentHashMap<Class, AttributeConverterDefinition>();
}
final Object old = attributeConverterDefinitionsByClass.put( definition.getAttributeConverter().getClass(), definition );
if ( old != null ) {
throw new AssertionFailure(
String.format(
"AttributeConverter class [%s] registered multiple times",
definition.getAttributeConverter().getClass()
)
);
}
}
项目:lams
文件:ToOneFkSecondPass.java
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
if ( value instanceof ManyToOne ) {
ManyToOne manyToOne = (ManyToOne) value;
PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
if ( ref == null ) {
throw new AnnotationException(
"@OneToOne or @ManyToOne on "
+ StringHelper.qualify( entityClassName, path )
+ " references an unknown entity: "
+ manyToOne.getReferencedEntityName()
);
}
BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );
TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings );
/*
* HbmMetadataSourceProcessorImpl does this only when property-ref != null, but IMO, it makes sense event if it is null
*/
if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
}
else if ( value instanceof OneToOne ) {
value.createForeignKey();
}
else {
throw new AssertionFailure( "FkSecondPass for a wrong value type: " + value.getClass().getName() );
}
}
项目:lams
文件:BinderHelper.java
public static MappedSuperclass getMappedSuperclassOrNull(
XClass declaringClass,
Map<XClass, InheritanceState> inheritanceStatePerClass,
Mappings mappings) {
boolean retrieve = false;
if ( declaringClass != null ) {
final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass );
if ( inheritanceState == null ) {
throw new org.hibernate.annotations.common.AssertionFailure(
"Declaring class is not found in the inheritance state hierarchy: " + declaringClass
);
}
if ( inheritanceState.isEmbeddableSuperclass() ) {
retrieve = true;
}
}
return retrieve ?
mappings.getMappedSuperclass( mappings.getReflectionManager().toClass( declaringClass ) ) :
null;
}
项目:lams
文件:AnnotationBinder.java
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) {
InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
clazzToProcess, inheritanceStatePerClass
);
PersistentClass superEntity = superEntityState != null ?
mappings.getClass(
superEntityState.getClazz().getName()
) :
null;
if ( superEntity == null ) {
//check if superclass is not a potential persistent class
if ( inheritanceState.hasParents() ) {
throw new AssertionFailure(
"Subclass has to be binded after it's mother class: "
+ superEntityState.getClazz().getName()
);
}
}
return superEntity;
}
项目:lams
文件:AnnotationBinder.java
private static void bindDiscriminatorColumnToRootPersistentClass(
RootClass rootClass,
Ejb3DiscriminatorColumn discriminatorColumn,
Map<String, Join> secondaryTables,
PropertyHolder propertyHolder,
Mappings mappings) {
if ( rootClass.getDiscriminator() == null ) {
if ( discriminatorColumn == null ) {
throw new AssertionFailure( "discriminator column should have been built" );
}
discriminatorColumn.setJoins( secondaryTables );
discriminatorColumn.setPropertyHolder( propertyHolder );
SimpleValue discriminatorColumnBinding = new SimpleValue( mappings, rootClass.getTable() );
rootClass.setDiscriminator( discriminatorColumnBinding );
discriminatorColumn.linkWithValue( discriminatorColumnBinding );
discriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
rootClass.setPolymorphic( true );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Setting discriminator for entity {0}", rootClass.getEntityName() );
}
}
}
项目:lams
文件:CollectionRemoveAction.java
/**
* Removes a persistent collection from its loaded owner.
*
* Use this constructor when the collection is non-null.
*
* @param collection The collection to to remove; must be non-null
* @param persister The collection's persister
* @param id The collection key
* @param emptySnapshot Indicates if the snapshot is empty
* @param session The session
*
* @throws AssertionFailure if collection is null.
*/
public CollectionRemoveAction(
final PersistentCollection collection,
final CollectionPersister persister,
final Serializable id,
final boolean emptySnapshot,
final SessionImplementor session) {
super( persister, collection, id, session );
if ( collection == null ) {
throw new AssertionFailure("collection == null");
}
this.emptySnapshot = emptySnapshot;
// the loaded owner will be set to null after the collection is removed,
// so capture its value as the affected owner so it is accessible to
// both pre- and post- events
this.affectedOwner = session.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
}
项目:lams
文件:QueryBinder.java
private static CacheMode getCacheMode(CacheModeType cacheModeType) {
switch ( cacheModeType ) {
case GET:
return CacheMode.GET;
case IGNORE:
return CacheMode.IGNORE;
case NORMAL:
return CacheMode.NORMAL;
case PUT:
return CacheMode.PUT;
case REFRESH:
return CacheMode.REFRESH;
default:
throw new AssertionFailure( "Unknown cacheModeType: " + cacheModeType );
}
}
项目:lams
文件:EntityBinding.java
public TableSpecification locateTable(String tableName) {
if ( tableName == null || tableName.equals( getPrimaryTableName() ) ) {
return primaryTable;
}
TableSpecification tableSpec = secondaryTables.get( tableName );
if ( tableSpec == null ) {
throw new AssertionFailure(
String.format(
"Unable to find table %s amongst tables %s",
tableName,
secondaryTables.keySet()
)
);
}
return tableSpec;
}
项目:lams
文件:StatefulPersistenceContext.java
@Override
public Object[] extractNaturalIdValues(Object entity, EntityPersister persister) {
if ( entity == null ) {
throw new AssertionFailure( "Entity from which to extract natural id value(s) cannot be null" );
}
if ( persister == null ) {
throw new AssertionFailure( "Persister to use in extracting natural id value(s) cannot be null" );
}
final int[] naturalIdentifierProperties = persister.getNaturalIdentifierProperties();
final Object[] naturalIdValues = new Object[naturalIdentifierProperties.length];
for ( int i = 0; i < naturalIdentifierProperties.length; i++ ) {
naturalIdValues[i] = persister.getPropertyValue( entity, naturalIdentifierProperties[i] );
}
return naturalIdValues;
}
项目:lams
文件:Binder.java
private EntityBinding createBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
if ( superEntityBinding == null ) {
return makeRootEntityBinding( (RootEntitySource) entitySource );
}
else {
switch ( currentInheritanceType ) {
case SINGLE_TABLE:
return makeDiscriminatedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
case JOINED:
return makeJoinedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
case TABLE_PER_CLASS:
return makeUnionedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
default:
// extreme internal error!
throw new AssertionFailure( "Internal condition failure" );
}
}
}
项目:lams
文件:HibernateTypeResolver.java
void resolve() {
for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
if ( entityBinding.getHierarchyDetails().getEntityDiscriminator() != null ) {
resolveDiscriminatorTypeInformation( entityBinding.getHierarchyDetails().getEntityDiscriminator() );
}
for ( AttributeBinding attributeBinding : entityBinding.attributeBindings() ) {
if ( SingularAttributeBinding.class.isInstance( attributeBinding ) ) {
resolveSingularAttributeTypeInformation(
SingularAttributeBinding.class.cast( attributeBinding )
);
}
else if ( AbstractPluralAttributeBinding.class.isInstance( attributeBinding ) ) {
resolvePluralAttributeTypeInformation(
AbstractPluralAttributeBinding.class.cast( attributeBinding )
);
}
else {
throw new AssertionFailure( "Unknown type of AttributeBinding: " + attributeBinding.getClass().getName() );
}
}
}
}
项目:lams
文件:HibernateTypeResolver.java
private void resolveSingularAttributeTypeInformation(SingularAttributeBinding attributeBinding) {
if ( attributeBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() != null ) {
return;
}
// we can determine the Hibernate Type if either:
// 1) the user explicitly named a Type in a HibernateTypeDescriptor
// 2) we know the java type of the attribute
Type resolvedType;
resolvedType = determineSingularTypeFromDescriptor( attributeBinding.getHibernateTypeDescriptor() );
if ( resolvedType == null ) {
if ( ! attributeBinding.getAttribute().isSingular() ) {
throw new AssertionFailure( "SingularAttributeBinding object has a plural attribute: " + attributeBinding.getAttribute().getName() );
}
final SingularAttribute singularAttribute = ( SingularAttribute ) attributeBinding.getAttribute();
if ( singularAttribute.getSingularAttributeType() != null ) {
resolvedType = getHeuristicType(
singularAttribute.getSingularAttributeType().getClassName(), new Properties()
);
}
}
if ( resolvedType != null ) {
pushHibernateTypeInformationDownIfNeeded( attributeBinding, resolvedType );
}
}
项目:lams
文件:RootEntitySourceImpl.java
@Override
public IdentifierSource getIdentifierSource() {
IdType idType = getEntityClass().getIdType();
switch ( idType ) {
case SIMPLE: {
BasicAttribute attribute = getEntityClass().getIdAttributes().iterator().next();
return new SimpleIdentifierSourceImpl( attribute, getEntityClass().getAttributeOverrideMap() );
}
case COMPOSED: {
throw new NotYetImplementedException( "Composed ids must still be implemented." );
}
case EMBEDDED: {
throw new NotYetImplementedException( "Embedded ids must still be implemented." );
}
default: {
throw new AssertionFailure( "The root entity needs to specify an identifier" );
}
}
}
项目:lams
文件:AttributeOverride.java
public AttributeOverride(String prefix, AnnotationInstance attributeOverrideAnnotation) {
if ( attributeOverrideAnnotation == null ) {
throw new IllegalArgumentException( "An AnnotationInstance needs to be passed" );
}
if ( !JPADotNames.ATTRIBUTE_OVERRIDE.equals( attributeOverrideAnnotation.name() ) ) {
throw new AssertionFailure( "A @AttributeOverride annotation needs to be passed to the constructor" );
}
columnValues = new ColumnValues(
JandexHelper.getValue(
attributeOverrideAnnotation,
"column",
AnnotationInstance.class
)
);
attributePath = createAttributePath(
prefix,
JandexHelper.getValue( attributeOverrideAnnotation, "name", String.class )
);
}
项目:lams
文件:ActionQueue.java
public void afterTransactionCompletion(boolean success) {
while ( !processes.isEmpty() ) {
try {
processes.poll().doAfterTransactionCompletion( success, session );
}
catch (CacheException ce) {
LOG.unableToReleaseCacheLock( ce );
// continue loop
}
catch (Exception e) {
throw new AssertionFailure( "Exception releasing cache locks", e );
}
}
if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
session.getFactory().getUpdateTimestampsCache().invalidate(
querySpacesToInvalidate.toArray( new String[querySpacesToInvalidate.size()] ),
session
);
}
querySpacesToInvalidate.clear();
}
项目:lams
文件:EnumeratedTypeResolver.java
@Override
protected Map<String, String> resolveHibernateTypeParameters(AnnotationInstance annotationInstance) {
HashMap<String, String> typeParameters = new HashMap<String, String>();
typeParameters.put( EnumType.ENUM, mappedAttribute.getAttributeType().getName() );
if ( annotationInstance != null ) {
javax.persistence.EnumType enumType = JandexHelper.getEnumValue(
annotationInstance,
"value",
javax.persistence.EnumType.class
);
if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) {
typeParameters.put( EnumType.TYPE, String.valueOf( Types.INTEGER ) );
}
else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) {
typeParameters.put( EnumType.TYPE, String.valueOf( Types.VARCHAR ) );
}
else {
throw new AssertionFailure( "Unknown EnumType: " + enumType );
}
}
else {
typeParameters.put( EnumType.TYPE, String.valueOf( Types.INTEGER ) );
}
return typeParameters;
}
项目:lams
文件:EntityCopyNotAllowedObserver.java
@Override
public void entityCopyDetected(
Object managedEntity,
Object mergeEntity1,
Object mergeEntity2,
EventSource session) {
if ( mergeEntity1 == managedEntity && mergeEntity2 == managedEntity) {
throw new AssertionFailure( "entity1 and entity2 are the same as managedEntity; must be different." );
}
final String managedEntityString = MessageHelper.infoString(
session.getEntityName( managedEntity ),
session.getIdentifier( managedEntity )
);
throw new IllegalStateException(
"Multiple representations of the same entity " + managedEntityString + " are being merged. " +
getManagedOrDetachedEntityString( managedEntity, mergeEntity1 ) + "; " +
getManagedOrDetachedEntityString( managedEntity, mergeEntity2 )
);
}
项目:lams
文件:EntityEntry.java
private EnumState(int offset, Class<E> enumType) {
E[] enumConstants = enumType.getEnumConstants();
// In case any of the enums cannot be stored in 4 bits anymore, we'd have to re-structure the compressed
// state int
if ( enumConstants.length > 15 ) {
throw new AssertionFailure( "Cannot store enum type " + enumType.getName() + " in compressed state as"
+ " it has too many values." );
}
this.offset = offset;
this.enumConstants = enumConstants;
// a mask for reading the four bits, starting at the right offset
this.mask = 0xF << offset;
// a mask for setting the four bits at the right offset to 0
this.unsetMask = 0xFFFF & ~mask;
}
项目:lams
文件:JandexHelper.java
/**
* @param annotations List of annotation instances keyed against their dot name.
* @param annotationName the annotation to retrieve from map
*
* @return the single annotation of the specified dot name or {@code null} in case the annotation is not specified at all
*
* @throws org.hibernate.AssertionFailure in case there is there is more than one annotation of this type.
*/
public static AnnotationInstance getSingleAnnotation(Map<DotName, List<AnnotationInstance>> annotations, DotName annotationName)
throws AssertionFailure {
List<AnnotationInstance> annotationList = annotations.get( annotationName );
if ( annotationList == null ) {
return null;
}
else if ( annotationList.size() == 1 ) {
return annotationList.get( 0 );
}
else {
throw new AssertionFailure(
"Found more than one instance of the annotation "
+ annotationList.get( 0 ).name().toString()
+ ". Expected was one."
);
}
}
项目:lams
文件:EnumConversionHelper.java
public static String generationTypeToGeneratorStrategyName(GenerationType generatorEnum, boolean useNewGeneratorMappings) {
switch ( generatorEnum ) {
case IDENTITY:
return "identity";
case AUTO:
return useNewGeneratorMappings
? "enhanced-sequence"
: "native";
case TABLE:
return useNewGeneratorMappings
? "enhanced-table"
: MultipleHiLoPerTableGenerator.class.getName();
case SEQUENCE:
return useNewGeneratorMappings
? "enhanced-sequence"
: "seqhilo";
}
throw new AssertionFailure( "Unknown GeneratorType: " + generatorEnum );
}
项目:lams
文件:EnumConversionHelper.java
public static CascadeStyle cascadeTypeToCascadeStyle(CascadeType cascadeType) {
switch ( cascadeType ) {
case ALL: {
return CascadeStyles.ALL;
}
case PERSIST: {
return CascadeStyles.PERSIST;
}
case MERGE: {
return CascadeStyles.MERGE;
}
case REMOVE: {
return CascadeStyles.DELETE;
}
case REFRESH: {
return CascadeStyles.REFRESH;
}
case DETACH: {
return CascadeStyles.EVICT;
}
default: {
throw new AssertionFailure( "Unknown cascade type" );
}
}
}
项目:lams
文件:EnumConversionHelper.java
public static FetchMode annotationFetchModeToHibernateFetchMode(org.hibernate.annotations.FetchMode annotationFetchMode) {
switch ( annotationFetchMode ) {
case JOIN: {
return FetchMode.JOIN;
}
case SELECT: {
return FetchMode.SELECT;
}
case SUBSELECT: {
// todo - is this correct? can the conversion be made w/o any additional information, eg
// todo - association nature
return FetchMode.SELECT;
}
default: {
throw new AssertionFailure( "Unknown fetch mode" );
}
}
}
项目:lams
文件:StatefulPersistenceContext.java
/**
* Add an collection to the cache, with a given collection entry.
*
* @param coll The collection for which we are adding an entry.
* @param entry The entry representing the collection.
* @param key The key of the collection's entry.
*/
private void addCollection(PersistentCollection coll, CollectionEntry entry, Serializable key) {
collectionEntries.put( coll, entry );
final CollectionKey collectionKey = new CollectionKey( entry.getLoadedPersister(), key );
final PersistentCollection old = collectionsByKey.put( collectionKey, coll );
if ( old != null ) {
if ( old == coll ) {
throw new AssertionFailure( "bug adding collection twice" );
}
// or should it actually throw an exception?
old.unsetSession( session );
collectionEntries.remove( old );
// watch out for a case where old is still referenced
// somewhere in the object graph! (which is a user error)
}
}
项目:lams
文件:AccessHelper.java
private static JaxbAccessType processIdAnnotations(List<AnnotationInstance> idAnnotations) {
JaxbAccessType accessType = null;
for ( AnnotationInstance annotation : idAnnotations ) {
AnnotationTarget tmpTarget = annotation.target();
if ( tmpTarget == null ) {
throw new AssertionFailure( "@Id has no AnnotationTarget, this is mostly a internal error." );
}
if ( accessType == null ) {
accessType = annotationTargetToAccessType( tmpTarget );
}
else {
if ( !accessType.equals( annotationTargetToAccessType( tmpTarget ) ) ) {
throw new MappingException( "Inconsistent placement of @Id annotation within hierarchy " );
}
}
}
return accessType;
}
项目:lams
文件:DefaultFlushEntityEventListener.java
/**
* make sure user didn't mangle the id
*/
public void checkId(Object object, EntityPersister persister, Serializable id, SessionImplementor session)
throws HibernateException {
if ( id != null && id instanceof DelayedPostInsertIdentifier ) {
// this is a situation where the entity id is assigned by a post-insert generator
// and was saved outside the transaction forcing it to be delayed
return;
}
if ( persister.canExtractIdOutOfEntity() ) {
Serializable oid = persister.getIdentifier( object, session );
if ( id == null ) {
throw new AssertionFailure( "null id in " + persister.getEntityName() + " entry (don't flush the Session after an exception occurs)" );
}
if ( !persister.getIdentifierType().isEqual( id, oid, session.getFactory() ) ) {
throw new HibernateException(
"identifier of an instance of " + persister.getEntityName() + " was altered from "
+ id + " to " + oid
);
}
}
}
项目:lams
文件:PersistentIndexedElementHolder.java
/**
* Constructs a PersistentIndexedElementHolder.
*
* @param session The session
* @param persister The collection persister
* @param key The collection key (fk value)@throws HibernateException
*/
public PersistentIndexedElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key) {
super( session );
final Element owner = (Element) session.getPersistenceContext().getCollectionOwner( key, persister );
if ( owner == null ) {
throw new AssertionFailure( "null owner" );
}
final String nodeName = persister.getNodeName();
if ( ".".equals( nodeName ) ) {
element = owner;
}
else {
element = owner.element( nodeName );
if ( element == null ) {
element = owner.addElement( nodeName );
}
}
}
项目:lams
文件:DefaultSaveOrUpdateEventListener.java
/**
* The given save-update event named a detached entity.
* <p/>
* Here, we will perform the update processing.
*
* @param event The update event to be handled.
*/
protected void entityIsDetached(SaveOrUpdateEvent event) {
LOG.trace( "Updating detached instance" );
if ( event.getSession().getPersistenceContext().isEntryFor( event.getEntity() ) ) {
//TODO: assertion only, could be optimized away
throw new AssertionFailure( "entity was persistent" );
}
Object entity = event.getEntity();
EntityPersister persister = event.getSession().getEntityPersister( event.getEntityName(), entity );
event.setRequestedId(
getUpdateId(
entity, persister, event.getRequestedId(), event.getSession()
)
);
performUpdate( event, entity, persister );
}
项目:lams
文件:SpecialOneToOneType.java
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
throws HibernateException {
if ( isNotEmbedded(session) ) {
return getIdentifierType(session).disassemble(value, session, owner);
}
if (value==null) {
return null;
}
else {
// cache the actual id of the object, not the value of the
// property-ref, which might not be initialized
Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session );
if (id==null) {
throw new AssertionFailure(
"cannot cache a reference to an object with a null id: " +
getAssociatedEntityName()
);
}
return getIdentifierType(session).disassemble(id, session, owner);
}
}
项目:lams
文件:ProxyFactoryFactoryImpl.java
public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
}
final javassist.util.proxy.ProxyFactory factory = new javassist.util.proxy.ProxyFactory();
factory.setFilter( FINALIZE_FILTER );
if ( superClass != null ) {
factory.setSuperclass( superClass );
}
if ( interfaces != null && interfaces.length > 0 ) {
factory.setInterfaces( interfaces );
}
proxyClass = factory.createClass();
}
项目:lams
文件:JpaNamingStrategyDelegate.java
@Override
public String determineImplicitEntityAssociationJoinColumnName(
String propertyEntityName, String propertyJpaEntityName, String propertyTableName, String referencedColumnName, String referencingPropertyName) {
// JPA states we should use the following as default:
// "The concatenation of the following: the name of the referencing relationship
// property or field of the referencing entity or embeddable class; "_"; the name
// of the referenced primary key column. If there is no such referencing relationship
// property or field in the entity, or if the join is for an element collection, the
// join column name is formed as the concatenation of the following: the name of the
// entity; "_"; the name of the referenced primary key column
// The part referring to an entity collection can be disregarded here since, determination of
// an element collection foreign key column name is covered by #entityAssociationJoinTableName().
//
// For a unidirectional association:
// {PROPERTY_ENTITY_NAME}_{REFERENCED_COLUMN_NAME}
// For a bidirectional association:
// {REFERENCING_PROPERTY_NAME}_{REFERENCED_COLUMN_NAME}
final String header;
if ( referencingPropertyName == null ) {
// This is a unidirectional association.
header = determineEntityNameToUse( propertyEntityName, propertyJpaEntityName );
}
else {
// This is a bidirectional association.
header = StringHelper.unqualify( referencingPropertyName );
}
if ( header == null ) {
throw new AssertionFailure( "propertyJpaEntityName and referencingPropertyName cannot both be empty." );
}
return toPhysicalColumnName( header + "_" + referencedColumnName );
}
项目:lams
文件:CollectionEntry.java
/**
* Called after a successful flush
*/
public void postFlush(PersistentCollection collection) throws HibernateException {
if ( isIgnore() ) {
ignore = false;
}
else if ( !isProcessed() ) {
throw new AssertionFailure( "collection [" + collection.getRole() + "] was not processed by flush()" );
}
collection.setSnapshot(loadedKey, role, snapshot);
}
项目:lams
文件:AbstractCollectionPersister.java
@Override
public EntityPersister getElementPersister() {
if ( elementPersister == null ) {
throw new AssertionFailure( "not an association" );
}
return elementPersister;
}
项目:lams
文件:EntityType.java
@Override
public Object replace(
Object original,
Object target,
SessionImplementor session,
Object owner,
Map copyCache) throws HibernateException {
if ( original == null ) {
return null;
}
Object cached = copyCache.get(original);
if ( cached != null ) {
return cached;
}
else {
if ( original == target ) {
return target;
}
if ( session.getContextEntityIdentifier( original ) == null &&
ForeignKeys.isTransient( associatedEntityName, original, Boolean.FALSE, session ) ) {
final Object copy = session.getEntityPersister( associatedEntityName, original )
.instantiate( null, session );
copyCache.put( original, copy );
return copy;
}
else {
Object id = getIdentifier( original, session );
if ( id == null ) {
throw new AssertionFailure("non-transient entity has a null id: " + original.getClass().getName());
}
id = getIdentifierOrUniqueKeyType( session.getFactory() )
.replace(id, null, session, owner, copyCache);
return resolve( id, session, owner );
}
}
}
项目:lams
文件:ToOneBinder.java
private static Class<?> getTargetEntityClass(XProperty property) {
final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
if (mTo != null) {
return mTo.targetEntity();
}
final OneToOne oTo = property.getAnnotation( OneToOne.class );
if (oTo != null) {
return oTo.targetEntity();
}
throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
}
项目:lams
文件:EJB3NamingStrategy.java
public String foreignKeyColumnName(
String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
) {
String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
if ( header == null ) throw new AssertionFailure( "NamingStrategy not properly filled" );
return columnName( header + "_" + referencedColumnName );
}
项目:lams
文件:AttributeConverterDefinition.java
private ParameterizedType extractAttributeConverterParameterizedType(Class attributeConverterClass) {
for ( Type type : attributeConverterClass.getGenericInterfaces() ) {
if ( ParameterizedType.class.isInstance( type ) ) {
final ParameterizedType parameterizedType = (ParameterizedType) type;
if ( AttributeConverter.class.equals( parameterizedType.getRawType() ) ) {
return parameterizedType;
}
}
}
throw new AssertionFailure(
"Could not extract ParameterizedType representation of AttributeConverter definition " +
"from AttributeConverter implementation class [" + attributeConverterClass.getName() + "]"
);
}
项目:lams
文件:CollectionEntry.java
/**
* Get the collection orphans (entities which were removed from the collection)
*/
public Collection getOrphans(String entityName, PersistentCollection collection)
throws HibernateException {
if (snapshot==null) {
throw new AssertionFailure("no collection snapshot for orphan delete");
}
return collection.getOrphans( snapshot, entityName );
}
项目:lams
文件:Ejb3JoinColumn.java
public void copyReferencedStructureAndCreateDefaultJoinColumns(
PersistentClass referencedEntity,
Iterator columnIterator,
SimpleValue value) {
if ( !isNameDeferred() ) {
throw new AssertionFailure( "Building implicit column but the column is not implicit" );
}
while ( columnIterator.hasNext() ) {
Column synthCol = (Column) columnIterator.next();
this.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value );
}
//reset for the future
setMappingColumn( null );
}
项目:lams
文件:DefaultComponentSafeNamingStrategy.java
public String foreignKeyColumnName(
String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
) {
String header = propertyName != null ? addUnderscores( propertyName ) : propertyTableName;
if ( header == null ) throw new AssertionFailure( "NamingStrategy not properly filled" );
return columnName( header + "_" + referencedColumnName );
}
项目:lams
文件:DefaultNamingStrategy.java
/**
* Return the property name or propertyTableName
*/
public String foreignKeyColumnName(
String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
) {
String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
if (header == null) throw new AssertionFailure("NammingStrategy not properly filled");
return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
}