Finalize moving annotations tests and ensure columns are sorted also for collection keys properly

This commit is contained in:
Christian Beikov 2022-01-06 14:14:01 +01:00
parent 1ede36212b
commit fb882f56f3
92 changed files with 296 additions and 220 deletions

View File

@ -183,7 +183,7 @@ public class InferredBasicValueResolver {
);
legacyType = jdbcMapping;
}
else if ( reflectedJtd instanceof SerializableJavaTypeDescriptor || reflectedJtd.getJavaType() instanceof Serializable ) {
else if ( reflectedJtd instanceof SerializableJavaTypeDescriptor || Serializable.class.isAssignableFrom( reflectedJtd.getJavaTypeClass() ) ) {
legacyType = new SerializableType<>( reflectedJtd );
jdbcMapping = legacyType;
}

View File

@ -140,6 +140,7 @@ import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.Set;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.SortableValue;
import org.hibernate.mapping.SyntheticProperty;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.UnionSubclass;
@ -275,6 +276,9 @@ public class ModelBinder {
applyCaching( mappingDocument, hierarchySource.getCaching(), rootEntityDescriptor );
if ( rootEntityDescriptor.getIdentifier() instanceof SortableValue ) {
( (SortableValue) rootEntityDescriptor.getIdentifier() ).sortProperties();
}
// Primary key constraint
rootEntityDescriptor.createPrimaryKey();
@ -606,7 +610,7 @@ public class ModelBinder {
}
// KEY
final SimpleValue keyBinding = new DependantValue(
final DependantValue keyBinding = new DependantValue(
mappingDocument,
primaryTable,
entityDescriptor.getIdentifier()
@ -618,7 +622,7 @@ public class ModelBinder {
keyBinding.setCascadeDeleteEnabled( entitySource.isCascadeDeleteEnabled() );
relationalObjectBinder.bindColumns(
mappingDocument,
sortColumns( entitySource.getPrimaryKeyColumnSources(), entityDescriptor.getIdentifier() ),
entitySource.getPrimaryKeyColumnSources(),
keyBinding,
false,
new RelationalObjectBinder.ColumnNamingDelegate() {
@ -630,6 +634,7 @@ public class ModelBinder {
}
}
);
keyBinding.sortProperties();
keyBinding.setForeignKeyName( entitySource.getExplicitForeignKeyName() );
// model.getKey().setType( new Type( model.getIdentifier() ) );
entityDescriptor.createPrimaryKey();
@ -1786,7 +1791,7 @@ public class ModelBinder {
);
}
final SimpleValue keyBinding = new DependantValue(
final DependantValue keyBinding = new DependantValue(
mappingDocument,
secondaryTable,
persistentClass.getIdentifier()
@ -1802,7 +1807,7 @@ public class ModelBinder {
relationalObjectBinder.bindColumns(
mappingDocument,
sortColumns( secondaryTableSource.getPrimaryKeyColumnSources(), persistentClass.getIdentifier() ),
secondaryTableSource.getPrimaryKeyColumnSources(),
keyBinding,
secondaryTableSource.isOptional(),
new RelationalObjectBinder.ColumnNamingDelegate() {
@ -1815,6 +1820,7 @@ public class ModelBinder {
}
);
keyBinding.sortProperties();
keyBinding.setForeignKeyName( secondaryTableSource.getExplicitForeignKeyName() );
// skip creating primary and foreign keys for a subselect.
@ -3432,6 +3438,7 @@ public class ModelBinder {
}
);
key.sortProperties();
key.createForeignKey();
getCollectionBinding().setKey( key );

View File

@ -699,7 +699,7 @@ public final class AnnotationBinder {
if ( inheritanceState.hasParents() ) {
onDeleteAppropriate = true;
final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass;
SimpleValue key = new DependantValue( context, jsc.getTable(), jsc.getIdentifier() );
DependantValue key = new DependantValue( context, jsc.getTable(), jsc.getIdentifier() );
jsc.setKey( key );
ForeignKey fk = clazzToProcess.getAnnotation( ForeignKey.class );
if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) {

View File

@ -156,6 +156,7 @@ public class BinderHelper {
clone.setValueGenerationStrategy( property.getValueGenerationStrategy() );
embeddedComp.addProperty( clone );
}
embeddedComp.sortProperties();
synthProp = new SyntheticProperty();
synthProp.setName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );

View File

@ -28,6 +28,7 @@ import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SortableValue;
import org.hibernate.type.ForeignKeyDirection;
/**
@ -258,6 +259,7 @@ public class OneToOneSecondPass implements SecondPass {
);
}
}
value.sortProperties();
}
/**
@ -278,7 +280,7 @@ public class OneToOneSecondPass implements SecondPass {
//no check constraints available on joins
join.setTable( originalJoin.getTable() );
join.setInverse( true );
SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
DependantValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
//TODO support @ForeignKey
join.setKey( key );
join.setSequentialSelect( false );
@ -303,6 +305,10 @@ public class OneToOneSecondPass implements SecondPass {
column.setGeneratedAs( column.getGeneratedAs() );
key.addColumn( copy );
}
if ( otherSideProperty.getValue() instanceof SortableValue
&& !( (SortableValue) otherSideProperty.getValue() ).isSorted() ) {
key.sortProperties();
}
persistentClass.addJoin( join );
return join;
}

View File

@ -1264,6 +1264,13 @@ public class BasicValueBinder<T> implements JdbcTypeDescriptorIndicators {
public void fillSimpleValue() {
LOG.debugf( "Starting `BasicValueBinder#fillSimpleValue` for %s", propertyName );
final String explicitBasicTypeName;
if ( this.explicitBasicTypeName != null ) {
explicitBasicTypeName = this.explicitBasicTypeName;
}
else {
explicitBasicTypeName = this.timeStampVersionType;
}
basicValue.setExplicitTypeName( explicitBasicTypeName );
basicValue.setExplicitTypeParams( explicitLocalTypeParams );

View File

@ -1387,7 +1387,7 @@ public abstract class CollectionBinder {
return orderByFragment;
}
private static SimpleValue buildCollectionKey(
private static DependantValue buildCollectionKey(
Collection collValue,
AnnotatedJoinColumn[] joinColumns,
boolean cascadeDeleteEnabled,
@ -1976,12 +1976,13 @@ public abstract class CollectionBinder {
catch (AnnotationException ex) {
throw new AnnotationException( "Unable to map collection " + collValue.getOwner().getClassName() + "." + property.getName(), ex );
}
SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled,
DependantValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled,
buildingContext.getBuildingOptions().isNoConstraintByDefault(), property, propertyHolder, buildingContext );
if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) {
joinColumns[0].setJPA2ElementCollection( true );
}
TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, buildingContext );
key.sortProperties();
}
public void setCascadeDeleteEnabled(boolean onDeleteCascade) {

View File

@ -926,11 +926,12 @@ public class EntityBinder {
}
private void bindJoinToPersistentClass(Join join, AnnotatedJoinColumn[] annotatedJoinColumns, MetadataBuildingContext buildingContext) {
SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
DependantValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
join.setKey( key );
setFKNameIfDefined( join );
key.setCascadeDeleteEnabled( false );
TableBinder.bindFk( persistentClass, null, annotatedJoinColumns, key, false, buildingContext );
key.sortProperties();
join.createPrimaryKey();
join.createForeignKey();
persistentClass.addJoin( join );

View File

@ -40,6 +40,7 @@ import org.hibernate.mapping.JoinedSubclass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SortableValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
@ -636,7 +637,9 @@ public class TableBinder {
linkJoinColumnWithValueOverridingNameIfImplicit(
referencedEntity, synthProp.getColumnIterator(), columns, value
);
if ( value instanceof SortableValue ) {
( (SortableValue) value ).sortProperties();
}
}
else {
if ( AnnotatedJoinColumn.NO_REFERENCE == fkEnum ) {
@ -655,6 +658,9 @@ public class TableBinder {
columns,
value
);
if ( value instanceof SortableValue ) {
( (SortableValue) value ).sortProperties();
}
}
else {
// Ensure the component is sorted so that we can simply set sorted to true on the to-one

View File

@ -40,7 +40,7 @@ import org.hibernate.type.Type;
* @author Gavin King
* @author Steve Ebersole
*/
public class Component extends SimpleValue implements MetaAttributable {
public class Component extends SimpleValue implements MetaAttributable, SortableValue {
private ArrayList<Property> properties = new ArrayList<>();
private int[] originalPropertyOrder = ArrayHelper.EMPTY_INT_ARRAY;
private String componentClassName;
@ -504,6 +504,12 @@ public class Component extends SimpleValue implements MetaAttributable {
getType();
}
@Override
public boolean isSorted() {
return originalPropertyOrder != ArrayHelper.EMPTY_INT_ARRAY;
}
@Override
public int[] sortProperties() {
return sortProperties( false );
}

View File

@ -17,10 +17,11 @@ import org.hibernate.type.Type;
*
* @author Gavin King
*/
public class DependantValue extends SimpleValue implements Resolvable {
public class DependantValue extends SimpleValue implements Resolvable, SortableValue {
private KeyValue wrappedValue;
private boolean nullable;
private boolean updateable;
private boolean sorted;
public DependantValue(MetadataBuildingContext buildingContext, Table table, KeyValue prototype) {
super( buildingContext, table );
@ -87,4 +88,26 @@ public class DependantValue extends SimpleValue implements Resolvable {
throw new UnsupportedOperationException("Trying to resolve the wrapped value but it is non a BasicValue");
}
@Override
public boolean isSorted() {
return sorted;
}
public void setSorted(boolean sorted) {
this.sorted = sorted;
}
@Override
public int[] sortProperties() {
if ( !sorted ) {
sorted = true;
if ( wrappedValue instanceof SortableValue ) {
final int[] originalOrder = ( (SortableValue) wrappedValue ).sortProperties();
if ( originalOrder != null ) {
sortColumns( originalOrder );
}
}
}
return null;
}
}

View File

@ -84,6 +84,7 @@ public class OneToOne extends ToOne {
}
}
@Override
public void createForeignKey() throws MappingException {
// Ensure properties are sorted before we create a foreign key
sortProperties();

View File

@ -169,7 +169,7 @@ public abstract class SimpleValue implements KeyValue {
updatability.add( false );
}
protected void sortColumns(int[] originalOrder) {
public void sortColumns(int[] originalOrder) {
final Selectable[] originalColumns = columns.toArray(new Selectable[0]);
final boolean[] originalInsertability = ArrayHelper.toBooleanArray( insertability );
final boolean[] originalUpdatability = ArrayHelper.toBooleanArray( updatability );

View File

@ -0,0 +1,17 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.mapping;
/**
*
*/
public interface SortableValue {
boolean isSorted();
int[] sortProperties();
}

View File

@ -21,7 +21,7 @@ import java.util.Objects;
* A simple-point association (ie. a reference to another entity).
* @author Gavin King
*/
public abstract class ToOne extends SimpleValue implements Fetchable {
public abstract class ToOne extends SimpleValue implements Fetchable, SortableValue {
private FetchMode fetchMode;
protected String referencedPropertyName;
private String referencedEntityName;
@ -145,6 +145,7 @@ public abstract class ToOne extends SimpleValue implements Fetchable {
this.referenceToPrimaryKey = referenceToPrimaryKey;
}
@Override
public boolean isSorted() {
return sorted;
}
@ -153,11 +154,8 @@ public abstract class ToOne extends SimpleValue implements Fetchable {
this.sorted = sorted;
}
public void sortProperties() {
if ( sorted ) {
return;
}
sorted = true;
@Override
public int[] sortProperties() {
final PersistentClass entityBinding = getMetadata().getEntityBinding( getReferencedEntityName() );
final Value value;
if ( getReferencedPropertyName() == null ) {
@ -169,9 +167,15 @@ public abstract class ToOne extends SimpleValue implements Fetchable {
if ( value instanceof Component ) {
final Component component = (Component) value;
final int[] originalPropertyOrder = component.sortProperties();
if ( originalPropertyOrder != null ) {
sortColumns( originalPropertyOrder );
if ( !sorted ) {
sorted = true;
if ( originalPropertyOrder != null ) {
sortColumns( originalPropertyOrder );
}
}
return originalPropertyOrder;
}
sorted = true;
return null;
}
}

View File

@ -43,6 +43,7 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.Resolvable;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SortableValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
@ -1011,7 +1012,11 @@ public class MappingModelCreationHelper {
}
else {
declaringKeyPart = simpleFkTarget;
declaringKeyPropertyAccess = ( (PropertyBasedMapping) declaringKeyPart ).getPropertyAccess();
// declaringKeyPropertyAccess = ( (PropertyBasedMapping) declaringKeyPart ).getPropertyAccess();
declaringKeyPropertyAccess = new ChainedPropertyAccessImpl(
attributeMapping.getPropertyAccess(),
( (PropertyBasedMapping) declaringKeyPart ).getPropertyAccess()
);
}
}
else {
@ -1220,7 +1225,8 @@ public class MappingModelCreationHelper {
if ( bootValueMapping instanceof Collection ) {
final Collection collectionBootValueMapping = (Collection) bootValueMapping;
componentType = (ComponentType) collectionBootValueMapping.getKey().getType();
sorted = false;
assert ( (SortableValue) collectionBootValueMapping.getKey() ).isSorted();
sorted = ( (SortableValue) collectionBootValueMapping.getKey() ).isSorted();
}
else {
final EntityType entityType = (EntityType) bootValueMapping.getType();
@ -1230,6 +1236,7 @@ public class MappingModelCreationHelper {
if ( identifierOrUniqueKeyType instanceof ComponentType ) {
componentType = (ComponentType) identifierOrUniqueKeyType;
if ( bootValueMapping instanceof ToOne ) {
assert ( (ToOne) bootValueMapping ).isSorted();
sorted = ( (ToOne) bootValueMapping ).isSorted();
}
else {

View File

@ -1193,7 +1193,7 @@ public final class StandardBasicTypes {
DbTimestampType.INSTANCE,
null,
basicTypeRegistry,
DbTimestampType.INSTANCE.getName()
DbTimestampType.INSTANCE.getName(), "dbtimestamp"
);
handle(

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.Entity;
/**

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import org.hibernate.cfg.PersistenceStandardNamingStrategy;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.internal.util.StringHelper;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -17,9 +17,6 @@ import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.sqm.UnknownEntityException;
import org.hibernate.test.annotations.Boat;
import org.hibernate.test.annotations.Ferry;
import org.hibernate.test.annotations.Port;
import org.junit.jupiter.api.Test;
import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import java.util.Collection;
import java.util.SortedSet;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.Entity;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.Entity;
/**

View File

@ -15,10 +15,6 @@ import org.hibernate.orm.test.annotations.inheritance.Tomato;
import org.hibernate.orm.test.annotations.inheritance.Vegetable;
import org.hibernate.orm.test.annotations.inheritance.VegetablePk;
import org.hibernate.test.annotations.AmericaCupClass;
import org.hibernate.test.annotations.Boat;
import org.hibernate.test.annotations.Country;
import org.hibernate.test.annotations.Ferry;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.AttributeOverride;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorColumn;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.util.Set;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -16,8 +16,6 @@ import org.hibernate.cfg.Environment;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.test.annotations.IncorrectEntity;
import static org.junit.Assert.fail;
/**

View File

@ -17,7 +17,6 @@ import org.hibernate.cfg.Environment;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.test.annotations.Plane;
import org.junit.Assert;
import org.junit.Test;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import jakarta.persistence.MappedSuperclass;
/**

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations;
package org.hibernate.orm.test.annotations;
import java.util.Comparator;
/**

View File

@ -11,7 +11,7 @@ import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.ManyToOne;
import org.hibernate.test.annotations.Country;
import org.hibernate.orm.test.annotations.Country;
/**
* @author Emmanuel Bernard

View File

@ -25,7 +25,7 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.hibernate.test.annotations.Country;
import org.hibernate.orm.test.annotations.Country;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@ -20,9 +20,9 @@ import org.hibernate.query.Query;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.test.annotations.A320;
import org.hibernate.test.annotations.A320b;
import org.hibernate.test.annotations.Plane;
import org.hibernate.orm.test.annotations.A320;
import org.hibernate.orm.test.annotations.A320b;
import org.hibernate.orm.test.annotations.Plane;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

View File

@ -19,11 +19,11 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.orm.test.annotations.Company;
import org.hibernate.test.annotations.Customer;
import org.hibernate.test.annotations.Discount;
import org.hibernate.orm.test.annotations.Customer;
import org.hibernate.orm.test.annotations.Discount;
import org.hibernate.orm.test.annotations.Flight;
import org.hibernate.test.annotations.Passport;
import org.hibernate.test.annotations.Ticket;
import org.hibernate.orm.test.annotations.Passport;
import org.hibernate.orm.test.annotations.Ticket;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Entity;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import org.hibernate.Session;
import org.hibernate.Transaction;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.manytoonewithformula;
package org.hibernate.orm.test.annotations.manytoonewithformula;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -43,11 +43,11 @@ import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.hibernate.test.annotations.Customer;
import org.hibernate.test.annotations.Discount;
import org.hibernate.test.annotations.Passport;
import org.hibernate.test.annotations.Ticket;
import org.hibernate.test.annotations.TicketComparator;
import org.hibernate.orm.test.annotations.Customer;
import org.hibernate.orm.test.annotations.Discount;
import org.hibernate.orm.test.annotations.Passport;
import org.hibernate.orm.test.annotations.Ticket;
import org.hibernate.orm.test.annotations.TicketComparator;
import org.junit.Assert;
import org.junit.Test;

View File

@ -23,10 +23,10 @@ import org.hibernate.mapping.Table;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.hibernate.testing.transaction.TransactionUtil;
import org.hibernate.test.annotations.Customer;
import org.hibernate.test.annotations.Discount;
import org.hibernate.test.annotations.Passport;
import org.hibernate.test.annotations.Ticket;
import org.hibernate.orm.test.annotations.Customer;
import org.hibernate.orm.test.annotations.Discount;
import org.hibernate.orm.test.annotations.Passport;
import org.hibernate.orm.test.annotations.Ticket;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.polymorphism;
package org.hibernate.orm.test.annotations.polymorphism;
public class Automobile {
}

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.polymorphism;
package org.hibernate.orm.test.annotations.polymorphism;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.polymorphism;
package org.hibernate.orm.test.annotations.polymorphism;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.polymorphism;
package org.hibernate.orm.test.annotations.polymorphism;
import org.junit.Test;
@ -33,7 +33,8 @@ public class PolymorphismTest extends BaseCoreFunctionalTestCase {
s.persist( car2 );
s.flush();
assertEquals( 2, s.createQuery( "select car from Car car").list().size() );
assertEquals( 0, s.createQuery( "select count(m) from " + Automobile.class.getName() + " m").list().size() );
// Support for querying a type which has no entity subtypes was removed and now throws an error
// assertEquals( 0, s.createQuery( "select count(m) from " + Automobile.class.getName() + " m").list().size() );
tx.rollback();
s.close();

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.polymorphism;
package org.hibernate.orm.test.annotations.polymorphism;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;

View File

@ -35,9 +35,9 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.hibernate.testing.orm.junit.SettingProvider;
import org.hibernate.testing.orm.junit.SkipForDialect;
import org.hibernate.test.annotations.A320;
import org.hibernate.test.annotations.A320b;
import org.hibernate.test.annotations.Plane;
import org.hibernate.orm.test.annotations.A320;
import org.hibernate.orm.test.annotations.A320b;
import org.hibernate.orm.test.annotations.Plane;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.Entity;
import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.AssociationOverride;
import jakarta.persistence.AssociationOverrides;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.io.Serializable;
import java.math.BigDecimal;
import jakarta.persistence.Entity;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Embeddable;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.io.Serializable;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import org.hibernate.Session;
import org.hibernate.Transaction;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.referencedcolumnname;
package org.hibernate.orm.test.annotations.referencedcolumnname;
import java.math.BigDecimal;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

View File

@ -6,13 +6,13 @@
*/
//$Id$
package org.hibernate.test.annotations.type;
package org.hibernate.orm.test.annotations.type;
import jakarta.persistence.AttributeOverride;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.GenericGenerator;
/**
@ -23,18 +23,13 @@ public class Dvd {
private MyOid id;
private String title;
@Id
@EmbeddedId
@GeneratedValue(generator = "custom-id")
@GenericGenerator(name = "custom-id", strategy = "org.hibernate.test.annotations.type.MyOidGenerator")
// @Type(type = "org.hibernate.test.annotations.type.MyOidType")
@Columns(
columns = {
@Column(name = "high"),
@Column(name = "middle"),
@Column(name = "low"),
@Column(name = "other")
}
)
@GenericGenerator(name = "custom-id", strategy = "org.hibernate.orm.test.annotations.type.MyOidGenerator")
@AttributeOverride(name = "aHigh", column = @Column(name = "high"))
@AttributeOverride(name = "aMiddle", column = @Column(name = "middle"))
@AttributeOverride(name = "aLow", column = @Column(name = "low"))
@AttributeOverride(name = "aOther", column = @Column(name = "other"))
public MyOid getId() {
return id;
}

View File

@ -0,0 +1,88 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
//$Id$
package org.hibernate.orm.test.annotations.type;
import java.io.Serializable;
import jakarta.persistence.Embeddable;
/**
* @author Emmanuel Bernard
*/
@Embeddable
public class MyOid implements Serializable {
private int aHigh;
private int aMiddle;
private int aLow;
private int aOther;
protected MyOid() {
}
public MyOid(int aHigh, int aMiddle, int aLow, int aOther) {
this.aHigh = aHigh;
this.aMiddle = aMiddle;
this.aLow = aLow;
this.aOther = aOther;
}
public int getaHigh() {
return aHigh;
}
public void setaHigh(int aHigh) {
this.aHigh = aHigh;
}
public int getaMiddle() {
return aMiddle;
}
public void setaMiddle(int aMiddle) {
this.aMiddle = aMiddle;
}
public int getaLow() {
return aLow;
}
public void setaLow(int aLow) {
this.aLow = aLow;
}
public int getaOther() {
return aOther;
}
public void setaOther(int aOther) {
this.aOther = aOther;
}
public boolean equals(Object o) {
if ( this == o ) return true;
if ( o == null || getClass() != o.getClass() ) return false;
final MyOid myOid = (MyOid) o;
if ( aHigh != myOid.aHigh ) return false;
if ( aLow != myOid.aLow ) return false;
if ( aMiddle != myOid.aMiddle ) return false;
if ( aOther != myOid.aOther ) return false;
return true;
}
public int hashCode() {
int result;
result = aLow;
result = 29 * result + aMiddle;
result = 29 * result + aHigh;
result = 29 * result + aOther;
return result;
}
}

View File

@ -6,7 +6,7 @@
*/
//$Id$
package org.hibernate.test.annotations.type;
package org.hibernate.orm.test.annotations.type;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.type;
package org.hibernate.orm.test.annotations.type;
import org.junit.Test;

View File

@ -6,7 +6,7 @@
*/
// $Id$
package org.hibernate.test.annotations.various;
package org.hibernate.orm.test.annotations.various;
import java.util.Date;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.various;
package org.hibernate.orm.test.annotations.various;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;

View File

@ -6,7 +6,7 @@
*/
// $Id$
package org.hibernate.test.annotations.various;
package org.hibernate.orm.test.annotations.various;
import java.util.Date;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.bootstrap.binding.annotations.access.jpa;
package org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;

View File

@ -1,85 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
//$Id$
package org.hibernate.test.annotations.type;
import java.io.Serializable;
/**
* @author Emmanuel Bernard
*/
public class MyOid implements Serializable {
private int high;
private int middle;
private int low;
private int other;
protected MyOid() {
}
public MyOid(int aHigh, int aMiddle, int aLow, int aOther) {
high = aHigh;
middle = aMiddle;
low = aLow;
other = aOther;
}
public int getHigh() {
return high;
}
public void setHigh(int aHigh) {
high = aHigh;
}
public int getMiddle() {
return middle;
}
public void setMiddle(int aMiddle) {
middle = aMiddle;
}
public int getLow() {
return low;
}
public void setLow(int aLow) {
low = aLow;
}
public int getOther() {
return other;
}
public void setOther(int aOther) {
other = aOther;
}
public boolean equals(Object o) {
if ( this == o ) return true;
if ( o == null || getClass() != o.getClass() ) return false;
final MyOid myOid = (MyOid) o;
if ( high != myOid.high ) return false;
if ( low != myOid.low ) return false;
if ( middle != myOid.middle ) return false;
if ( other != myOid.other ) return false;
return true;
}
public int hashCode() {
int result;
result = low;
result = 29 * result + middle;
result = 29 * result + high;
result = 29 * result + other;
return result;
}
}

View File

@ -17,7 +17,7 @@
-->
<hibernate-mapping package="org.hibernate.test.annotations">
<hibernate-mapping package="org.hibernate.orm.test.annotations">
<class name="Boat" table="BoatInXml">

View File

@ -18,9 +18,9 @@
-->
<hibernate-mapping package="org.hibernate.test.annotations">
<hibernate-mapping package="org.hibernate.orm.test.annotations">
<joined-subclass name="Ferry" table="FerryJoined" extends="org.hibernate.test.annotations.Boat">
<joined-subclass name="Ferry" table="FerryJoined" extends="org.hibernate.orm.test.annotations.Boat">
<key column="id"/>
<property name="sea"/>

View File

@ -10,8 +10,8 @@
<hibernate-configuration>
<session-factory>
<mapping resource="org/hibernate/test/annotations/Boat.hbm.xml"/>
<mapping package="org.hibernate.test.annotations"/>
<mapping class="org.hibernate.test.annotations.Plane"/>
<mapping resource="org/hibernate/orm/test/annotations/Boat.hbm.xml"/>
<mapping package="org.hibernate.orm.test.annotations"/>
<mapping class="org.hibernate.orm.test.annotations.Plane"/>
</session-factory>
</hibernate-configuration>